有没有办法强制测试我的电子邮件模板的文本版本。我的所有电子邮件帐户都查看HTML,我需要确保正确显示文本版本。
$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);
答案 0 :(得分:2)
在不更改代码的情况下,轻松实现此操作的方法是,使用电子邮件客户端查看原始电子邮件。
例如,使用Gmail,您可以转到右上角的箭头(回复旁边),然后选择“消息文字乱码”或“显示原始文件”