开发者

Encoding problems when sending email with PHP to Hotmail

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       = "to@email.com";
$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<john@doe.com>" . "\r\n" . 
"From: John Smith<john@smith.com" . "\r\n" .
"Reply-To: john@doe.com" . "\r\n" .
"Return-Path: john@doe.com" . "\r\n" .
"Sender: john@doe.com" . "\r\n" .
"X-Sender: john@doe.com" . "\r\n" .
"X-Mailer: JohnDoe". "\r\n".
"X-Report-Abuse: Please report abuse to: john@doe.com";

//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);


Try http://www.phpclasses.org/browse/file/919.html. It works for Yahoo mail, Gmail, Hotmail.

P.S.: Hotmail sucks. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜