使用电子邮件发送特殊字符()

时间:2013-05-23 13:08:22

标签: php email html-entities

我不明白我做错了什么。我有一个联系表单,用以下代码发送消息:

$SUCCESS = mail(

    $EMAIL_TO,

    "Richiesta informazioni",

    "Questo messaggio e' stato inviato tramite la pagina 'Contatti' del sito ".$WEBSITE."; non rispondere a questo messaggio ma servirsi dei contatti lasciati dal mittente.\r\n\r\n".
    "Inviato da: ".$_POST['nome']."\r\n".
    "IP Address: ".$_SERVER['REMOTE_ADDR']."\r\n".
    "Contatti: ".$_POST['contatti']."\r\n".
    "------------------------------------------------------\r\n".
    $_POST['messaggio']."\r\n",

    "Reply-To: ".$COMPANY." <".$EMAIL_TO.">\r\n".
    "Return-Path: ".$COMPANY." <".$EMAIL_TO.">\r\n".
    "From: ".$COMPANY." <".$WEBSITE.">\r\n".
    "Organization: ".$COMPANY."\r\n".
    "MIME-Version: 1.0\r\n".
    "Content-type: text/plain; charset=utf-8\r\n".
    "Content-Transfer-Encoding: 8bit",

    "-f".$EMAIL_TO

);

问题是,如果我发送特殊字符......

¡
¢
£
¤
¥

...我收到翻译的字符:

&Acirc;&iexcl;
&Acirc;&cent;
&Acirc;&pound;
&Acirc;&curren;
&Acirc;&yen;

当然,我已尝试过其他讨论中提出的许多解决方案:

// it's just a list - not the code I used! I've tryed lots of combinations.
iconv_set_encoding("internal_encoding", "UTF-8");
iconv_set_encoding("output_encoding", "ISO-8859-1");
htmlspecialchars(...);
mb_convert_encoding(...);

我使用 mb_convert_encoding 来查看结果:

$message = mb_convert_encoding($message, 'UTF-8', 'HTML-ENTITIES');

但它不是一个明确的解决方案,因为如果我使用这个函数,我会得到:

¡
¢
£
¤
Â¥

对不起,这个问题对社区没用!不幸的是,我没有想法,我需要帮助......我缺少什么?

1 个答案:

答案 0 :(得分:0)

更改标题:

 "Content-Type: text/plain; charset=UTF-8\n";

 "Content-Type: text/html; charset=UTF-8\n";

下面的代码 我已经改变了你可以添加n检查

"Reply-To: ".$COMPANY." <".$EMAIL_TO.">\r\n".
"Return-Path: ".$COMPANY." <".$EMAIL_TO.">\r\n".
"From: ".$COMPANY." <".$WEBSITE.">\r\n".
"Organization: ".$COMPANY."\r\n".
"MIME-Version: 1.0\r\n".
"Content-Type: text/html; charset=UTF-8\r\n".
"Content-Transfer-Encoding: 8bit",

"-f".$EMAIL_TO

我检查了以下代码及其工作

<?php
mail(

    "check with ur email",

    "Richiesta informazioni",

    "Questo messaggio e' stato inviato tramite la pagina 'Contatti' del sito; non rispondere a questo messaggio ma servirsi dei contatti lasciati dal mittente.\r\n\r\n".
    "Inviato da: santanu\r\n".
    "IP Address: santanu\r\n".
    "Contatti: santanu\r\n".
    "------------------------------------------------------\r\n
    message ¡
¢
£
¤
¥\r\n",

    "Reply-To: test <your email>\r\n".
    "Return-Path: test<your email>\r\n".
    "From: test <your email>\r\n".
    "Organization: test\r\n".
    "MIME-Version: 1.0\r\n".
    "Content-type: text/html; charset=utf-8\r\n".
    "Content-Transfer-Encoding: 8bit",

    "-fyour email"

);

?>