php邮件:如何发送html?
发布时间:2020-12-13 16:36:50 所属栏目:PHP教程 来源:网络整理
导读:以下代码正确发送电子邮件,但是正文.我需要在消息的正文中显示html,我无法做到.网络中的示例不会发送电子邮件:( 如何解决我的代码发送电子邮件与身体的HTML? 万分感谢! ?php$to = 'mymail@mail.com';$subject = 'I need to show html'; $from ='example@ex
以下代码正确发送电子邮件,但是正文.我需要在消息的正文中显示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 . "rnReply-To: " . $from . ""; $headers .= "Content-type: text/htmlrn"; if (mail($to,$subject,$body,$headers)) { echo("<p>Sent</p>"); } else { echo("<p>Error...</p>"); } ?>
使用此标头的邮件:
$header = "MIME-Version: 1.0rn"; $header .= "Content-type: text/html; charset: utf8rn"; 对于内容/主体: <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> ... ... ... 重要的是使用内联css命令并建议使用表格作为界面. … 在你的邮件身上你不得不把HTML code with head and body (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |