当我尝试从PHP发送HTML编码的电子邮件时,如果主题行包含特殊字符"Here's the information you requested"
,则PHP将其编码为读取"Here's the information you requested."
我该如何解决?
以下是使用PHP mail()的代码:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: ' . $mod_params['name'] . '<' . $mod_params['email'] . '>' . "\r\n";
$headers .= 'From: <do_not_reply@a4isp.com>' . "\r\n";
$email_to = $mod_params['email'];
$email_sub = "Here's the Information You Requested";
$body = html_entity_decode("<html><body>" . $email_html_body . "</body></html>");
mail($email_to,$email_sub,$body,$headers);
它给出了与通过SugarPHPMailer类运行它相同的错误。
发布于 2018-08-28 09:57:55
尝试这个:
$newsubject='=?UTF-8?B?'.base64_encode($subject).'?=';
这样您就不依赖于PHP或MTA的编码,您可以完成这项工作,而邮件客户端应该理解它。您的新主题中不会出现任何特殊字符,因此在发送电子邮件时不会出现任何问题。
https://stackoverflow.com/questions/-100000676
复制相似问题