{"id":1155,"date":"2018-04-13T17:15:41","date_gmt":"2018-04-13T09:15:41","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=1155"},"modified":"2018-04-13T17:34:15","modified_gmt":"2018-04-13T09:34:15","slug":"phpmailer-smtp-error-failed-to-connect-to-server-permission-denied-13","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/centos\/2018\/04\/13\/1715411155.html","title":{"rendered":"phpmailer  SMTP ERROR: Failed to connect to server: Permission denied (13)"},"content":{"rendered":"<p>1\u3001ThinkPHP\u5728\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93PHPMailer\u53d1\u9001\u90ae\u4ef6\u65f6\u62a5\u9519\uff0c\u5982\u9898\u6240\u793a\uff0c\u4f55\u89e3\uff1b<\/p>\n<p>2\u3001\u6b64\u5904\u7701\u7565\u6392\u9519\u8fc7\u7a0b\u7684\u51e0\u5341\u4e07\u5b57&#8230;..<\/p>\n<p>3\u3001\u6211\u7684\u670d\u52a1\u5668CentOS7\uff0c\u6709\u79cd\u4e1c\u897f\u53eb\u201cSELinux\u201d\uff0c\u81f3\u4e8e\u8fd9\u662f\u4e2a\u4ec0\u4e48\u4e1c\u897f\uff0c\u518d\u6b21\u7701\u7565\u51e0\u4e07\u5b57\uff1b<\/p>\n<p>4\u3001\u6b63\u9898\uff0c\u5728linux\u4e0b\u67e5\u770b\u4e24\u4e2a\u72b6\u6001<br \/>\n<code>$ getsebool httpd_can_sendmail<br \/>\nhttpd_can_sendmail --> off<br \/>\n$ getsebool httpd_can_network_connect<br \/>\nhttpd_can_network_connect --> off<\/code><\/p>\n<p>5\u3001\u5982\u679c\u540e\u9762\u5e26off\uff0c\u5219\u5f88\u6709\u53ef\u80fd\u4e0e\u8fd9\u4e2a\u6709\u5173\uff0c\u5982\u679c\u662fon\uff0c\u6b64\u6587\u5bf9\u4f60\u65e0\u7528\uff0c\u540e\u9762\u7684\u5c31\u4e0d\u8981\u770b\u4e86\uff1b<\/p>\n<p>6\u3001\u4e24\u6761\u547d\u4ee4\u5c06\u8be5\u4e24\u9879\u5b89\u5168\u9879\u6253\u5f00\uff0c\u95ee\u9898\u5f97\u4ee5\u89e3\u51b3\uff01<br \/>\n<code>$ setsebool -P httpd_can_sendmail 1<br \/>\n$ setsebool -P httpd_can_network_connect 1<\/code><\/p>\n<p>7\u3001\u5982\u679c\u8fd8\u6d89\u53ca\u5230\u5176\u4ed6\u7aef\u53e3\uff0c\u4e0d\u5982\u5e72\u8106\u5148\u628aSELinux\u6682\u65f6\u5173\u95ed<br \/>\n<code>$setenforce 0<\/code><\/p>\n<p>\u53c2\u8003\u94fe\u63a5\uff1a<a href=\"https:\/\/gistpages.com\/posts\/phpmailer_smtp_error_failed_to_connect_to_server_permission_denied_13_fix\" rel=\"noopener\" target=\"_blank\">https:\/\/gistpages.com\/posts\/phpmailer_smtp_error_failed_to_connect_to_server_permission_denied_13_fix<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001ThinkPHP\u5728\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93PHPMailer\u53d1\u9001\u90ae\u4ef6\u65f6\u62a5\u9519\uff0c\u5982\u9898\u6240\u793a\uff0c\u4f55\u89e3\uff1b 2\u3001\u6b64\u5904\u7701\u7565\u6392\u9519\u8fc7\u7a0b\u7684\u51e0\u5341\u4e07\u5b57&#8230;.. 3\u3001\u6211\u7684\u670d\u52a1\u5668CentOS7\uff0c\u6709\u79cd\u4e1c\u897f\u53eb\u201cSELinux\u201d\uff0c\u81f3\u4e8e\u8fd9\u662f\u4e2a\u4ec0\u4e48\u4e1c\u897f\uff0c\u518d\u6b21\u7701\u7565\u51e0\u4e07\u5b57\uff1b 4\u3001\u6b63\u9898\uff0c\u5728linux\u4e0b\u67e5\u770b\u4e24\u4e2a\u72b6\u6001 $ getsebool httpd_can_sendmail httpd_can_sendmail &#8211;> off $ getsebool httpd_can_network_connect httpd_can_network_connect &#8211;> off 5\u3001\u5982\u679c\u540e\u9762\u5e26off\uff0c\u5219\u5f88\u6709\u53ef\u80fd\u4e0e\u8fd9\u4e2a\u6709\u5173\uff0c\u5982\u679c\u662fon\uff0c\u6b64\u6587\u5bf9\u4f60\u65e0\u7528\uff0c\u540e\u9762\u7684\u5c31\u4e0d\u8981\u770b\u4e86\uff1b 6\u3001\u4e24\u6761\u547d\u4ee4\u5c06\u8be5\u4e24\u9879\u5b89\u5168\u9879\u6253\u5f00\uff0c\u95ee\u9898\u5f97\u4ee5\u89e3\u51b3\uff01 $ setsebool -P httpd_can_sendmail 1 $ setsebool -P httpd_can_network_connect 1 7\u3001\u5982\u679c\u8fd8\u6d89\u53ca\u5230\u5176\u4ed6\u7aef\u53e3\uff0c\u4e0d\u5982\u5e72\u8106\u5148\u628aSELinux\u6682\u65f6\u5173\u95ed $setenforce 0 \u53c2\u8003\u94fe\u63a5\uff1ahttps:\/\/gistpages.com\/posts\/phpmailer_smtp_error_failed_to_connect_to_server_permission_denied_13_fix<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[6,71,70],"class_list":["post-1155","post","type-post","status-publish","format-standard","hentry","category-centos","tag-php","tag-phpmailer","tag-thinkphp"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=1155"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1155\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=1155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=1155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=1155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}