I would like to be able to send e-mails with PHP mail() containing the 8-bit characters åäö. They will be used in the subject, the message and in the \"From:\"-header. How c
Use the swiftmailer library. http://swiftmailer.org/
$headers = array('From' => $from,
'To' => "<$to>",
'Subject' => $subject);
if ($is_html) {
$headers['Content-type'] = "text/html; charset=UTF-8";
} else {
$headers['Content-type'] = "text/plain; charset=UTF-8";
}
This works for me
Simplest solution if you don't mind encoding even words that don't need it is to put everything in a base64 RFC 2047 encoded-word:
$subject= "=?utf-8?b?".base64_encode($subject)."?=";
$body= "blah blah $utf8text blah";
$headers= "MIME-Version: 1.0\r\n";
$headers.= "From: =?utf-8?b?".base64_encode($fromname)."?= <$fromaddress>\r\n";
$headers.= "Content-Type: text/plain;charset=utf-8";
mail($toaddress, $subject, $body, $headers);