On this sites Website Link contact form I need to send the subject for email in UTF-8. Where in the code we need to do declare the UTF-8 encoding?
kontakt.php:
<?
require_once "php/sendmail.class.php";
$sendmail = new sendMail();
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$sendmail->setParams($_POST);
$sendmail->parseBody();
$sendmail->setHeaders();
if ($sendmail->send())
{
header('Location: kontakt.php?success=1');
}
}
?>
sendmail.class.php:
class sendMail {
var $to = 'email'; // set contact email
var $name = '';
var $subject = '';
var $email = '';
var $body = '';
var $error = array();
var $headers = array();
function setHeaders()
{
$this->headers = "From: $this->email\r\n";
$this->headers.= "MIME-Version: 1.0\r\n";
$this->headers.= "Content-type: text/html; charset=UTF-8\r\n";
}
function parseBody()
{
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= '<tr style="background-color: #eee;"><td><strong>Name:</strong> </td><td>' . $this->name . '</td></tr>';
$message .= "<tr><td><strong>E-Mail-Adresse:</strong> </td><td>" . $this->email . "</td></tr>";
$message .= "<tr><td><strong>Betreff:</strong> </td><td>" . $this->subject . "</td></tr>";
$message .= "<tr><td><strong>Text:</strong> </td><td>" . $this->body . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$this->body = $message;
}
function send()
{
if ($this->error)
{
return FALSE;
}
if (mail($this->to, $this->subject, $this->body, $this->headers))
{
return TRUE;
}
else
{
$this->error[] = 'Fehler beim senden';
return FALSE;
}
In the subject I need the utf 8 german characters encoding. Where do we need to declare it in the code? For the message I found out what to do but for the subject I found no solution.