I am using the following code to send email to members of my site. The script works and the email is recieved by the user. But, I do encounter encoding problems when emailing to Hotmail or Notes.
The code:
$to = "[email protected]";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset="utf-8"; format="flowed"' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n";
$headers .= "To: John Doe<[email protected]>" . "\r\n" .
"From: John Smith<[email protected]" . "\r\n" .
"Reply-To: [email protected]" . "\r\n" .
"Return-Path: [email protected]" . "\r\n" .
"Sender: [email protected]" . "\r\n" .
"X-Sender: [email protected]" . "\r\n" .
"X-Mailer: JohnDoe". "\r\n".
"X-Report-Abuse: Please report abuse to: [email protected]";
//If the e-mail was successfully sent...
$subject = $translation[104];
if(mail($to, $subject, $message, $headers)){
}
Both the message and the subject contains the swedish letters Å, Ä and Ö. The actual message is correctly encoded and viewed in Hotmail, while the subject is not. You can view the image below for more information:
Image: http://www.aspkoll.se/imgo/649
I am confused. I've googled for days and tried different kind of solutions, but without any success I am afraid.
Can you please help me with this problem?
Appreciated!
Email subjects, and other header content, such as names, are encoded using RFC 2047
php.net comments on mail() give the following example:
mail($mail, "=?utf-8?B?".base64_encode ($subject)."?=", $message, $headers);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With