php邮件特殊字符utf8

时间:2013-10-31 13:40:10

标签: php email special-characters

我有以下脚本:

<?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!

2 个答案:

答案 0 :(得分:12)

您是否尝试过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");?>

答案 1 :(得分:-1)

使用&rsquo;代替'。

示例:

The dog&rsquo;s bone.

确保将内容类型从text / plain更改为text / html。