php html和文本电子邮件,强制发送文本版本
有没有办法强制测试我的电子邮件模板的文本版本。我的所有电子邮件帐户都查看HTML,我需要确保文本版本显示正确php html和文本电子邮件,强制发送文本版本,php,Php,有没有办法强制测试我的电子邮件模板的文本版本。我的所有电子邮件帐户都查看HTML,我需要确保文本版本显示正确 $mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x'; $headers = "MIME-Version: 1.0" . "\r\n"; $headers.= "Content-Type: multipart/alternative; boundary=" .$mime_boundary.
$mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers.= "Content-Type: multipart/alternative; boundary=" .$mime_boundary. "\r\n";
$headers.= "Content-Type: text/html; charset=UTF-8" . "\r\n";
$headers.= "Content-Transfer-Encoding: 7bit" . "\r\n";
$text_content = file_get_contents('emails/welcome_txt.tpl');
$html_content = file_get_contents('emails/welcome.tpl');
$body = "--{$mime_boundary}--\n";
$body.= "Content-Type: text/plain; charset=charset=us-ascii\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $text_content;
$body.= "\n\n";
$body.= "--{$mime_boundary}--\n";
$body.= "--{$mime_boundary}--\n";
$body.= "Content-Type: text/html; charset=iso-8859-\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $html_content;
$body.= "\n\n";
$body.= "--{$mime_boundary}\n";
$body = str_replace("{Username}",$en['user'],$html_content);
mail($en['email'], $subject, $body, $headers, '-f' . $returnpath);
不更改代码的简单方法是,使用电子邮件客户端查看原始电子邮件
例如,使用Gmail,您可以转到右上箭头(回复旁边),然后选择“消息文本乱码”或“显示原始内容”难道您不能只注释掉有边界的$body部分并包含html文本吗?另一种方法是配置您的电子邮件客户端,并将其指定为只接收文本而不接收html。仅供参考,它会显示您在许多客户端中看到的电子邮件预览。我想你可能会发现它很方便。@TimWithers我考虑过了,但我想看看完整的过程,以确保没有错误或打嗝。@juand谢谢,我会检查出来的