且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SMTP错误:无法连接到服务器:权限被拒绝(13)

更新时间:2023-01-22 10:10:07

让我们首先获得答案!尝试使用以下命令:

Let's get to the answer first of all! Try with the following command:

$ getsebool httpd_can_sendmail

如果显示:httpd_can_sendmail --> off

为此打开它:

$ sudo setsebool -P httpd_can_sendmail 1

然后尝试再次发送电子邮件.

then try sending the email again.

此解决方案来自于出色的页面.

This solution comes from this great page.

如本文所指出,您可能还需要尝试sudo setsebool -P httpd_can_network_connect 1.对于由DigitalOcean托管的CentOS 7虚拟机,这不是必需的.

As it was pointed out from this article, you may also need to try sudo setsebool -P httpd_can_network_connect 1. While for my CentOS 7 vm hosted by DigitalOcean, it's not necessary.

我遇到的问题是无法从Drupal网站发送带有SMTP身份验证支持模块的电子邮件,该模块依赖于下面的PHPMailer.所使用的SMTP服务器是Google.

The problem I met was failing to send out emails from a Drupal website, with the SMTP Authentication Support module, which relies on PHPMailer underneath. And the SMTP server used was Google.

顺便说一句,我怀疑这是OpenSSL证书问题,做了一些测试,但是没有运气.因此,通过将PHPMailer源代码中的$SMTPDebug级别设置为2,我可以捕获权限被拒绝(13)"错误消息.

BTW, I had suspected it was OpenSSL certificate problem and did some test but no luck. So by setting the $SMTPDebug level to 2 from the PHPMailer source code, I was able to capture the "Permission denied (13)" error message.