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
Testmail ? Special Characters
身体:
Hi there, this isn?t something easy. I haven?t thought that it?s that complicated!
我尝试了很多东西,但我没有任何想法了。 你可以帮我吗? 你有没有这个工作?
谢谢!
你尝试过iconv_set_encoding吗?
这应该工作:
<?php iconv_set_encoding("internal_encoding", "UTF-8"); $subject = "Testmail — Special Characters"; $msg = "Hi there,\n\nthis isn't something easy.\n\nI haven't thought that it's that complicated!"; mail(utf8_decode($to), utf8_decode($subject), utf8_decode($msg), utf8_decode($from)."\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n");?>
使用’
代替'。
例:
The dog’s bone.
确保您将内容types从文本/纯文本更改为文本/ html。