电子邮件内容中的奇怪字符仅限于AOL帐户?

时间:2017-02-13 20:07:20

标签: php email html-email

我得到抱怨奇怪字符的客户

  

捐款收据:    A

     

如果捐赠者提供了额外信息,请参阅以下信息:   Â

这只发生在AOL上。或者至少,似乎只发生在那里。

这是邮件通话。

  $headers .= "From: " . "Jewcer  <info@myapp.com>" . "\r\n";
  $headers .= "Reply-To: " . "info@myapp.com" . "\r\n";
  $headers .= "From: " . "<{$fromEmail}>" . "\r\n";
  $headers .= "Reply-To: " . "{$fromEmail}" . "\r\n";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  mail($to, $title, $content, $headers);

知道可能导致此问题的原因是什么?通常它的工作原理,只是AOL和其他一些奇怪的客户导致问题

1 个答案:

答案 0 :(得分:0)

对我来说唯一有用的是:

function utf8mail($to,$s,$body,$from_name="x",$from_a = "info@x.com", $reply="info@x.com")
{
    $s= "=?utf-8?b?".base64_encode($s)."?=";
    $headers = "MIME-Version: 1.0\r\n";
    $headers.= "From: =?utf-8?b?".base64_encode($from_name)."?= <".$from_a.">\r\n";
    $headers.= "Content-Type: text/plain;charset=utf-8\r\n";
    $headers.= "Reply-To: $reply\r\n";  
    $headers.= "X-Mailer: PHP/" . phpversion();
    mail($to, $s, $body, $headers);
}

https://stackoverflow.com/a/7267426/533426