{"id":1154,"date":"2014-06-21T16:06:09","date_gmt":"2014-06-21T08:06:09","guid":{"rendered":"http:\/\/www.51cos.com\/?p=1154"},"modified":"2014-06-21T16:06:09","modified_gmt":"2014-06-21T08:06:09","slug":"%e4%bd%bf%e7%94%a8phpmailer%e5%8f%91%e9%80%81%e9%82%ae%e4%bb%b6%e5%ae%9e%e7%8e%b0android-app%e6%89%be%e5%9b%9e%e5%af%86%e7%a0%81%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"http:\/\/www.51cos.com\/?p=1154","title":{"rendered":"\u4f7f\u7528phpMailer\u53d1\u9001\u90ae\u4ef6\u5b9e\u73b0Android APP\u627e\u56de\u5bc6\u7801\u529f\u80fd"},"content":{"rendered":"<p>phpMailer\u529f\u80fd\u5f3a\u5927\uff0c\u4f7f\u7528\u8d77\u6765\u5374\u6781\u5176\u7b80\u5355\uff0c\u5728\u4f60\u5b89\u88c5\u5b8clnmp\u540e\uff0c\u6309\u7167\u4e0b\u9762\u7684\u6b65\u9aa4\u8d70\u5373\u53ef\uff1a<\/p>\n<p>1.\u4e0b\u8f7dphpMailer\u00a0 <a href=\"http:\/\/www.51cos.com\/wp-content\/uploads\/2014\/06\/phpMailer_v2.3.zip\">phpMailer_v2.3<\/a><\/p>\n<p>2.class.phpmailer.php class.smtp.php\u8fd9\u4e24\u4e2a\u6587\u4ef6\u590d\u5236\u5230\u4f60\u7684php\u76ee\u5f55\u4e0b<\/p>\n<p>3.\u5728\u4f60\u7684php\u76ee\u5f55\u521b\u5efasendemail.php\u00a0 \u5185\u5bb9\u5982\u4e0b\u5373\u53ef\uff1a<\/p>\n<blockquote><p>require_once(&#8220;class.phpmailer.php&#8221;); \/\/phpmailer\u5e93<\/p>\n<p><span class=\"katex math inline\">mail = new PHPMailer(); \/\/\u5b9e\u4f8b\u5316<\/span>mail-&gt;IsSMTP(); \/\/ \u542f\u7528SMTP<br \/>\n<span class=\"katex math inline\">mail-&gt;Host = &#8220;smtp.exmail.qq.com&#8221;; \/\/SMTP\u670d\u52a1\u5668 \u4ee5qq\u4f01\u4e1a\u90ae\u7bb1\u4e3a\u4f8b\u5b50<\/span>mail-&gt;Port = 25;\u00a0 \/\/\u90ae\u4ef6\u53d1\u9001\u7aef\u53e3<br \/>\n<span class=\"katex math inline\">mail-&gt;SMTPAuth\u00a0\u00a0 = true;\u00a0 \/\/\u542f\u7528SMTP\u8ba4\u8bc1<\/span>mail-&gt;CharSet\u00a0 = &#8220;UTF-8&#8221;; \/\/\u5b57\u7b26\u96c6<br \/>\n<span class=\"katex math inline\">mail-&gt;Encoding = &#8220;base64&#8221;; \/\/\u7f16\u7801\u65b9\u5f0f<\/span>mail-&gt;Username = &#8220;xxxxx@iwo.com&#8221;;\u00a0 \/\/\u4f60\u7684\u90ae\u7bb1<br \/>\n<span class=\"katex math inline\">mail-&gt;Password = &#8220;xxxxx&#8221;;\u00a0 \/\/\u4f60\u7684\u5bc6\u7801<\/span>mail-&gt;Subject = &#8220;\u627e\u56de\u5bc6\u7801&#8221;; \/\/\u90ae\u4ef6\u6807\u9898<\/p>\n<p><span class=\"katex math inline\">mail-&gt;From = &#8220;xxxxx@iwo.com&#8221;;\u00a0 \/\/\u53d1\u4ef6\u4eba\u5730\u5740\uff08\u4e5f\u5c31\u662f\u4f60\u7684\u90ae\u7bb1\uff09<\/span>mail-&gt;FromName = &#8220;APP Server&#8221;;\u00a0 \/\/\u53d1\u4ef6\u4eba\u59d3\u540d<\/p>\n<p><span class=\"katex math inline\">address =<\/span>data_json-&gt;email;\/\/\u6536\u4ef6\u4ebaemail ,\u8fd9\u91cc\u662f\u5b89\u5353APP\u63d0\u4ea4\u8fc7\u6765\u7684<br \/>\n<span class=\"katex math inline\">mail-&gt;AddAddress(<\/span>address, &#8220;&#8221;);\/\/\u6dfb\u52a0\u6536\u4ef6\u4eba\uff08\u5730\u5740\uff0c\u6635\u79f0\uff08\u53ef\u9009\uff09\uff09<\/p>\n<p><span class=\"katex math inline\">mail-&gt;IsHTML(true); \/\/\u652f\u6301html\u683c\u5f0f\u5185\u5bb9<\/span>mail-&gt;Body = &#8216;\u60a8\u597d\uff0c\u60a8\u7684\u5bc6\u7801\u662f\uff1a&#8217;.<span class=\"katex math inline\">rowdata[0]; \/\/\u90ae\u4ef6\u4e3b\u4f53\u5185\u5bb9<\/p>\n<p>\/\/\u53d1\u9001<br \/>\nif(!<\/span>mail-&gt;Send()) {<br \/>\n\/\/ fail<br \/>\n<span class=\"katex math inline\">response[&#8220;action&#8221;] = &#8220;getpwd&#8221;;<\/span>response[&#8220;errorid&#8221;] = 704;<br \/>\n<span class=\"katex math inline\">response[&#8220;message&#8221;] = &#8220;Send Email Error: &#8220;.<\/span>mail-&gt;ErrorInfo;<br \/>\nprint(json_encode(<span class=\"katex math inline\">response));<br \/>\n} else {<\/span>response[&#8220;action&#8221;] = &#8220;getpwd&#8221;;<br \/>\n<span class=\"katex math inline\">response[&#8220;errorid&#8221;] = 0;<br \/>\nprint(json_encode(<\/span>response));<br \/>\n}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>phpMailer\u529f\u80fd\u5f3a\u5927\uff0c\u4f7f\u7528\u8d77\u6765\u5374\u6781\u5176\u7b80\u5355\uff0c\u5728\u4f60\u5b89\u88c5\u5b8clnmp\u540e\uff0c\u6309\u7167\u4e0b\u9762\u7684\u6b65\u9aa4\u8d70\u5373\u53ef\uff1a 1.\u4e0b\u8f7dphpM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1154","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1154"}],"version-history":[{"count":0,"href":"http:\/\/www.51cos.com\/index.php?rest_route=\/wp\/v2\/posts\/1154\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1154"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.51cos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}