我有以下脚本:PHP的邮件特殊字符UTF8
<?php
$subject = "Testmail — Special Characters";
$msg = "Hi there,\n\nthis isn’t something easy.\n\nI haven’t thought that it’s that complicated!";
mail($to,$subject,$msg,$from."\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n");
?>
在电子邮件:
主题:Testmail ? Special Characters
身体:
Hi there,
this isn?t something easy.
I haven?t thought that it?s that complicated!
我尝试了很多东西,但我没有任何想法了。 你能帮我吗?你有没有这个工作?
THX!
哇,它适用于身体,但不适用于主题:“Testmail 特殊字符” 想法? –
@JohnDoeSmith:原因是你不能utf8_decode()这样的字符,比如长破折号,没有等效的1字节表示。我不明白你如何接受这个答案 –
使用[mb_encode_mimeheader](http://php.net/manual/en/function.mb-encode-mimeheader.php)为主题: $ subject = mb_encode_mimeheader($受试者, “UTF-8”); – GregTheRules