UTF-8 encoding for subject in contact form email

Solution 1:

here is how i did it:

$head = "From: \"=?ISO-8859-15?Q?".imap_8bit("äöüßÄÖÜ sollte hier gehen")."?=\" <[email protected]>\n";
$subject = "=?ISO-8859-15?Q?".imap_8bit("äöüßÄÖÜ sollte hier gehen")."?=";
mail($mail,$subject,$text,$head);

that is ofc just Latin-15 (German) encoding. utf-8 works the same way: look here for a great explanation on how to use character encoding in mail headers: http://ncona.com/2011/06/using-utf-8-characters-on-an-e-mail-subject/

for your code you have to change this in the sendmail class:

if (mail($this->to, '=?utf-8?B?'.base64_encode($this->subject).'?=', $this->body, $this->headers))

! this only works properly if your php file is utf-8 encoded !

still very annoying. then i switched to phpmailer. that does everything for you. way more easy. i would suggest you use that.