前端之家收集整理的这篇文章主要介绍了
php邮件:如何发送html?,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_
404_0@
以下
代码正确发送电子
邮件,但是正文.我需要在消息的正文中
显示html,我无法做到.网络中的示例不会发送电子
邮件:(
如何解决我的代码发送电子邮件与身体的HTML?
万分感谢!
<?PHP
$to = 'mymail@mail.com';
$subject = 'I need to show html';
$from ='example@example.com';
$body = '<p style=color:red;>This text should be red</p>';
ini_set("sendmail_from",$from);
$headers = "From: " . $from . "\r\nReply-To: " . $from . "";
$headers .= "Content-type: text/html\r\n";
if (mail($to,$subject,$body,$headers)) {
echo("<p>Sent</p>");
} else {
echo("<p>Error...</p>");
}
?>
使用此标头的
邮件:
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset: utf8\r\n";
对于内容/主体:
<html>
<head>
<Meta http-equiv="content-type" content="text/html; charset=utf-8" />
... ... ...
重要的是使用内联css命令并建议使用表格作为界面.
…
在你的邮件身上你不得不把HTML code with head and body