问题描述:

Imagine the following:

$from = "Testäöå <[email protected]>";

....

$headers = array ('From' => $from,

'To' => $to,

'Subject' => $subject,

'MIME-Version' => "1.0",

'Content-type' => "text/html; charset=iso-8859-1");

If the $from variable is just "Test <[email protected]>", script works fine.

网友答案:

Since you're specifying the headers directly, you need to escape them manually. Only ASCII characters are allowed in headers, so you need to escape them.

You can do that i.e. with

'=?UTF-8?B?'.base64_encode($from).'?='

Alternatively, you can use the Multibyte string functions as described in the comments of http://pear.php.net/manual/en/package.mail.mail.send.php :

$encodedFrom = mb_encode_mimeheader($from, 'UTF-8', 'Q');
相关阅读:
Top