php-SMTP错误:无法连接到服务器:权限被拒绝(13)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-SMTP错误:无法连接到服务器:权限被拒绝(13),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2136字,纯文字阅读大概需要4分钟。
内容图文
![php-SMTP错误:无法连接到服务器:权限被拒绝(13)](/upload/InfoBanner/zyjiaocheng/682/7f94cd026b3a4c6ab326298429e22e88.jpg)
美好的一天!
我试图让我的phpmailer在我的共享主机(freehostia.com)中工作,我总是收到此错误.我的gmail用户名和密码是正确的,其余设置如下所示:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'tls://smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mymail@gmail.com'; // SMTP username
$mail->Password = 'mypassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('mymail@gmail.com', 'ASAPHOT Administrator'); // Add a recipient
$mail->addAddress('sorianorobertc@gmail.com'); // Name is optional
$mail->addReplyTo('mymail@gmail.com', 'ASAPHOT Administrator');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'it works';
$mail->Body = 'it works';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
openssl在php.ini中也未注释.我在这里想念什么吗?谢谢.
完整的错误消息:
Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
SMTP ERROR: Failed to connect to server: Permission denied (13)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
解决方法:
让我们首先得到答案!尝试使用以下命令:
$getsebool httpd_can_sendmail
如果显示:httpd_can_sendmail->关
用这个打开它:
$sudo setsebool -P httpd_can_sendmail 1
然后尝试再次发送电子邮件.
这个解决方案来自这个伟大的page.
正如本文指出的那样,您可能还需要尝试sudo setsebool -P httpd_can_network_connect1.对于由DigitalOcean托管的CentOS 7虚拟机,则没有必要.
我遇到的问题是无法从Drupal网站发送带有SMTP身份验证支持模块的电子邮件,该模块依赖于下面的PHPMailer.使用的SMTP服务器是Google.
顺便说一句,我怀疑这是OpenSSL证书问题,做了一些测试,但是没有运气.因此,通过从PHPMailer源代码中将$SMTPDebug级别设置为2,我能够捕获到“权限被拒绝(13)”错误消息.
内容总结
以上是互联网集市为您收集整理的php-SMTP错误:无法连接到服务器:权限被拒绝(13)全部内容,希望文章能够帮你解决php-SMTP错误:无法连接到服务器:权限被拒绝(13)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。