使用php发送html电子邮件作为html代码传递消息 [英] send html email using php deliver message as html code
本文介绍了使用php发送html电子邮件作为html代码传递消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
iam发送html消息包含表
iam sending html message contains table
当我在gmail,hotmail,yahoo帐户上接收消息时,它工作正常,但在其他客户端
上接收时即Microsoft前景它将其解析为html代码!!
when i recive message on gmail,hotmail,yahoo account it works fine but when receiving on other client ie Microsoft outlook it resolve it as html code !!
这是我的电子邮件标题
'MIME-Version: 1.0' . "\r\n" .
'Content-Type: text/html;charset= UTF-8' . "\r\n" .
'From: me <me@client.com>'
推荐答案
我始终使用此功能,并且对
I Always use this function ,and it helps
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);
}
这篇关于使用php发送html电子邮件作为html代码传递消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文