我的html电子邮件welcome.tpl文件格式已更正我使用PutsMail对其进行了测试,并且下面的代码处理并发送电子邮件但HTML未呈现。我得到的只是电子邮件中的实际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-Transfer-Encoding: 7bit\r\n";
$headers.= "From: <support@system.com>" . "\r\n";
$headers.= "X-Sender-IP: $_SERVER[SERVER_ADDR]" . "\r\n";
$headers.= "Date: ".date('n/d/Y g:i A') . "\r\n";
$headers.= "Reply-To: my" . "\r\n";
$subject='New Reg';
$body.= "{$mime_boundary}\n";
$body.= "Content-Type: text/html; charset=iso-8859-2\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $html_content;
$body.= "\n\n";
$body.= "--{$mime_boundary}\n";
$html_content = file_get_contents('emails/welcome.tpl');
$body = str_replace("{Username}",$en['user'],$html_content);
mail($en['email'], $subject, $body, $headers);
答案 0 :(得分:3)
使用并检查:
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
希望有所帮助
答案 1 :(得分:1)
所有边界都需要“ - ”前置,最后(关闭)mime边界需要附加“ - ”,所以
$body.= "[--]{$mime_boundary}\n";
应改为
$body.= "--{$mime_boundary}--\n";
在最后一次出现时到
$body.= "--{$mime_boundary}\n";
除了最后一次出现之外的所有事件。