iam发送html消息包含表
当我在gmail,hotmail,yahoo帐户上收到消息时,它工作正常,但在其他客户端收到时 即Microsoft Outlook它将其解析为HTML代码!!
这是我的电子邮件标题
'MIME-Version: 1.0' . "\r\n" .
'Content-Type: text/html;charset= UTF-8' . "\r\n" .
'From: me <me@client.com>'
答案 0 :(得分:0)
我总是使用这个功能,它有帮助
function sendHTMLemail($HTML,$from,$to,$subject,$fromname)
{
$headers = "From: ".$fromname." <".$from.">\r\n";
$headers.= "Reply-To: ".$fromname." <".$from.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("HTMLEMAIL");
// First we be nice and send a non-html version of our email
$headers .= "Content-Type: multipart/alternative;".
"boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$headers .= "--$boundary\r\n".
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode(strip_tags($HTML)));
// Now we attach the HTML version
$headers .= "--$boundary\r\n".
"Content-Type: text/html; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($HTML));
// And then send the email ....
mail($to,$subject,"",$headers);
}
答案 1 :(得分:0)
我知道这不是您问题的答案,但我建议您使用邮件库,以便更轻松地发送邮件,并支持附件,身份验证等功能。 我建议SwiftMailer效果很好,很简单且记录良好。