用PHP发送HTML电子邮件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用PHP发送HTML电子邮件相关的知识,希望对你有一定的参考价值。
/* EXAMPLE: htmlmail('[email protected]', 'Look ma, HTML e-mails','You just got <a href="http://www.yougotrickrolled.com/">Rick Rolled</a>'); NOTE: $headers is optional, but can be used to set From, CC, etc. Go to http://www.htmlite.com/php029.php for info */ function htmlmail($to, $subject, $message, $headers = NULL) { $headers .= "MIME-Version: 1.0 "; $headers .= "Content-Type: multipart/alternative;boundary={$mime_boundary} "; $newmessage = "This is a multi-part message in MIME format."; $newmessage .= " --{$mime_boundary} "; $newmessage .= "Content-type: text/plain;charset=utf-8 "; $newmessage .= " --{$mime_boundary} "; $newmessage .= "Content-type: text/html;charset=utf-8 "; // prepended HTML $newmessage .= '<body style="margin:0"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#ffffff" valign="top"><table width="750" border="0" cellpadding="0" cellspacing="0" align="center"><tr><td bgcolor="#ffffff" width="750">'; // HTML message that was passed to this function $newmessage .= $message; // appended HTML $newmessage .= '</td></tr></table></td></tr></table></body>'; }
以上是关于用PHP发送HTML电子邮件的主要内容,如果未能解决你的问题,请参考以下文章