title: UTF-8 encoding for subject in contact form email
body: <p>On this sites <a href="http://dh-creative-webdesign.de/kontakt.php" rel="noreferrer">Website Link</a> 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?</p>
  
  <p>kontakt.php:</p>
  
  <pre><code>&lt;?
  require_once "php/sendmail.class.php";
  $sendmail = new sendMail();
  if ($_SERVER['REQUEST_METHOD'] == 'POST')
  {
  $sendmail-&gt;setParams($_POST);
  $sendmail-&gt;parseBody();
  $sendmail-&gt;setHeaders();
  if ($sendmail-&gt;send())
  {
      header('Location: kontakt.php?success=1');
  }
  }
  ?&gt;
  </code></pre>
  
  <p>sendmail.class.php:</p>
  
  <pre><code>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-&gt;headers = "From: $this-&gt;email\r\n";
      $this-&gt;headers.= "MIME-Version: 1.0\r\n";
      $this-&gt;headers.= "Content-type: text/html; charset=UTF-8\r\n";
  }
  
  function parseBody()
  {
      $message     = '&lt;html&gt;&lt;body&gt;';
      $message .= '&lt;table rules="all" style="border-color: #666;" cellpadding="10"&gt;';
      $message .= '&lt;tr style="background-color: #eee;"&gt;&lt;td&gt;&lt;strong&gt;Name:&lt;/strong&gt; &lt;/td&gt;&lt;td&gt;' . $this-&gt;name . '&lt;/td&gt;&lt;/tr&gt;';
      $message .= "&lt;tr&gt;&lt;td&gt;&lt;strong&gt;E-Mail-Adresse:&lt;/strong&gt; &lt;/td&gt;&lt;td&gt;" . $this-&gt;email . "&lt;/td&gt;&lt;/tr&gt;";
      $message .= "&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Betreff:&lt;/strong&gt; &lt;/td&gt;&lt;td&gt;" . $this-&gt;subject . "&lt;/td&gt;&lt;/tr&gt;";
      $message .= "&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Text:&lt;/strong&gt; &lt;/td&gt;&lt;td&gt;" . $this-&gt;body . "&lt;/td&gt;&lt;/tr&gt;";
      $message .= "&lt;/table&gt;";
      $message .= "&lt;/body&gt;&lt;/html&gt;";
      $this-&gt;body  = $message;
  }
  
  function send()
  {
      if ($this-&gt;error)
      {
          return FALSE;
      }
  
      if (mail($this-&gt;to, $this-&gt;subject, $this-&gt;body, $this-&gt;headers))
      {
          return TRUE;
      }
      else
      {
          $this-&gt;error[] = 'Fehler beim senden';
          return FALSE;
      }
  </code></pre>
  
  <p>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. </p>