我创建了一个html电子邮件welcome.tpl
我必须使用什么PHP邮件方法才能将该文件作为邮件正文发送出去?在此之前,我一直在使用,并包括变量处理HTML电子邮件模板文件和php
$text_content.= "\r\n";
$text_content.= "--------------------------------\r\n";
$html_content.= "</body></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";
$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.= "Content-Type: text/html; charset=\"UTF-8\"\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $html_content;
$body.= "\n\n";
$body.= "--$mime_boundary--\n";
$headers.= 'From: So <[email protected]>' . "\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: So <[email protected]>' . "\r\n";
mail($en['email'], $subject, $body, $headers);
HTML和文字,我应该使用类似$body = file_get_contents();
,是mail();
最好的方法是什么?
的看看?你可以显示welcome.tpl和邮件功能的重要部分吗? – Jomoos 2011-12-19 11:21:07
@Jomoos我已经添加了我目前的邮件()函数的片段...至于welcome.tpl它只是基本的HTML使用所需的电子邮件只能接受的HTML/CSS – acctman 2011-12-19 16:26:46