{"id":5906,"date":"2013-12-12T20:00:40","date_gmt":"2013-12-12T12:00:40","guid":{"rendered":"http:\/\/jpuyy.com\/?p=5906"},"modified":"2013-12-12T20:07:06","modified_gmt":"2013-12-12T12:07:06","slug":"email-html-format","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=5906","title":{"rendered":"email\u7684html\u6392\u7248"},"content":{"rendered":"<p>\u7528\u7a0b\u5e8f\u751f\u6210\u597d\u4e00\u4e2a\u90ae\u4ef6\u6807\u9898\u548c\u5185\u5bb9\uff0c\u4e4b\u540e\u60f3\u8981\u5b8c\u7f8e\u7684\u5728\u6536\u4ef6\u7bb1\u91cc\u63a5\u6536\uff0c\u9700\u8981\u7f16\u5199\u9488\u5bf9\u4e8e\u90ae\u4ef6\u7684html\u3002<\/p>\n<p>\u7f8e\u89c2\u53ef\u4ee5\u653e\u5728\u7b2c\u4e8c\u4f4d\uff0c\u4f46\u662f\u9700\u8981\u8ba9\u90ae\u7bb1\u8ba4\u51fa\u662fhtml\u6765\uff0c\u5426\u5219\u5185\u5bb9\u4f1a\u4ee5\u539f\u7801\u663e\u793a\u3002<\/p>\n<p>\u5728\u90ae\u4ef6headers\u4e2d\u52a0\u5165\u6b63\u786e\u7684Content-type\u548ccharset\u5373\u53ef\u3002<\/p>\n<p>email html\u4e2d\u7684\u5e03\u5c40\u57fa\u672c\u662f\u7528table\uff0ccss\u6837\u5f0f\u5c3d\u91cf\u76f4\u63a5\u5199\u5728html\u6807\u7b7e\u91cc\uff0c\u4ee5\u4e0b\u5206\u522b\u662f\u7528\u539f\u751fphp\u548cphp-mail(SMTP)\u6765\u53d1\u90ae\u4ef6\u3002<\/p>\n<pre>&lt;?php\r\n\r\n$message='\r\n\r\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\"&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;title&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;table&gt;\r\n&lt;tr&gt;\r\n&lt;th&gt;three days forcast&lt;\/th&gt;\r\n&lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;';\r\n\r\n$to = 'youmail@gmail.com';\r\n\r\n$subject =send mail using php;\r\n$from = \"yourmail@163.com\";\r\n$headers = \"From: $from\\n\";\r\n$headers .= \"Reply-To: $from\\n\";\r\n$headers .= \"MIME-Version: 1.0\\n\";\r\n$headers .= \"Content-type: text\/html; charset=iso-8859-1\";\r\n\r\nmail($to, $subject, $message,$headers);\r\necho \"Mail Sent.\";\r\n\r\n?&gt;<\/pre>\n<p>\u4f7f\u7528pear mail(SMTP)\u53d1\u9001\u90ae\u4ef6<\/p>\n<pre>&lt;?php\r\n\r\n\/\/require apt-get install php-mail, reference: http:\/\/php.net\/manual\/en\/function.mail.php\r\ninclude(\"Mail.php\");\r\n\r\n$message='\r\n\r\n&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\"&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;title&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;table&gt;\r\n&lt;tr&gt;\r\n&lt;th&gt;three days forcast&lt;\/th&gt;\r\n&lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;';\r\n\r\n$to = 'youmail@gmail.com';\r\n\r\n$subject =send mail using php;\r\n\r\n$headers[\"From\"] = \"yourmail@163.com\";\r\n$headers[\"TO\"] = \"yourmail@gmail.com\";\r\n$headers[\"Subject\"] = \"$subject\";\r\n$headers[\"MIME-Version\"] = \"1.0\";\r\n$headers[\"Content-type\"] = \"text\/html\";\r\n$headers[\"charset\"] = \"iso-8859-1\";\r\n\r\n$params[\"host\"] = \"smtp.163.com\";\r\n$params[\"port\"] = \"25\";\r\n$params[\"auth\"] = true;\r\n$params[\"username\"] = \"yourmail@163.com\";\r\n$params[\"password\"] = \"yourpassword\";\r\n\r\n$mail_object = &amp; Mail::factory(\"smtp\", $params);\r\n\r\n$mail_object-&gt;send($to, $headers, $message);\r\n\r\n\/\/echo $message;\r\necho \"Mail Sent.\";\r\n\r\n?&gt;<\/pre>\n<p>\u53c2\u8003\uff1a<a href=\"http:\/\/johndoesdesign.com\/blog\/2012\/php\/getting-your-php-html-email-to-render-in-gmail\/\">http:\/\/johndoesdesign.com\/blog\/2012\/php\/getting-your-php-html-email-to-render-in-gmail\/<\/a><\/p>\n<p><a href=\"http:\/\/email.about.com\/od\/emailprogrammingtips\/qt\/PHP_Email_SMTP_Authentication.htm\">http:\/\/email.about.com\/od\/emailprogrammingtips\/qt\/PHP_Email_SMTP_Authentication.htm<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7528\u7a0b\u5e8f\u751f\u6210\u597d\u4e00\u4e2a\u90ae\u4ef6\u6807\u9898\u548c\u5185\u5bb9\uff0c\u4e4b\u540e\u60f3\u8981\u5b8c\u7f8e\u7684\u5728\u6536\u4ef6\u7bb1\u91cc\u63a5\u6536\uff0c\u9700\u8981\u7f16\u5199\u9488\u5bf9\u4e8e\u90ae\u4ef6\u7684html\u3002 \u7f8e\u89c2\u53ef\u4ee5\u653e\u5728\u7b2c\u4e8c\u4f4d\uff0c\u4f46\u662f\u9700\u8981\u8ba9\u90ae\u7bb1\u8ba4\u51fa\u662fhtml\u6765\uff0c\u5426\u5219\u5185\u5bb9\u4f1a\u4ee5\u539f\u7801\u663e\u793a\u3002 \u5728\u90ae\u4ef6headers\u4e2d\u52a0\u5165\u6b63\u786e\u7684Content-type\u548ccharset\u5373\u53ef\u3002 email html\u4e2d\u7684\u5e03\u5c40\u57fa\u672c\u662f\u7528table\uff0ccss\u6837\u5f0f\u5c3d\u91cf\u76f4\u63a5\u5199\u5728html\u6807\u7b7e\u91cc\uff0c\u4ee5\u4e0b\u5206\u522b\u662f\u7528\u539f\u751fphp\u548cphp-mail(SMTP)\u6765\u53d1\u90ae\u4ef6\u3002 &lt;?php $message=&#8217; &lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD HTML 4.01\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/html4\/strict.dtd&#8221;&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;title&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;three days forcast&lt;\/th&gt; &lt;\/tr&gt; &lt;\/table&gt; &lt;\/body&gt; &lt;\/html&gt;&#8217;; $to = &#8216;youmail@gmail.com&#8217;; $subject =send mail using php; $from = &#8220;yourmail@163.com&#8221;; $headers = &#8220;From: $from\\n&#8221;; $headers .= &#8220;Reply-To: $from\\n&#8221;; $headers .= &#8220;MIME-Version: 1.0\\n&#8221;; $headers .= &#8220;Content-type: text\/html; [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[164],"class_list":["post-5906","post","type-post","status-publish","format-standard","hentry","category-life","tag-smtp"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5906"}],"version-history":[{"count":12,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5906\/revisions"}],"predecessor-version":[{"id":5973,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/5906\/revisions\/5973"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}