Java321技术网

 找回密码
 立即注册
搜索
热搜: centos
查看: 12549|回复: 0
打印 上一主题 下一主题

PHPMailer发送邮件出现Permission denied的解决办法

[复制链接]

126

主题

126

帖子

815

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
815
跳转到指定楼层
楼主
发表于 2017-11-6 23:52:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
使用PHPMailer发送邮件, 可能会出现Permission denied错误, 如下:

2016-06-30 04:05:00 Connection: opening to smtp.exmail.qq.com:25, timeout=300, options=array ( ) 2016-06-30 04:05:04 SMTP ERROR: Failed to connect to server: Permission denied (13) 2016-06-30 04:05:04 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

这是因为selinux拒绝httpd服务发送邮件, 可以修改selinux的规则。 步骤如下:

1、使用下面的命令查看selinux的权限。

getsebool -a  | grep httpd_can_sendmail

OR

getsebool httpd_can_sendmail

2、再使用下面的命令允许httpd发送邮件。

setsebool -P httpd_can_sendmail 1

OR

/usr/sbin/setsebool-P httpd_can_sendmail on

OR

setsebool httpd_can_sendmail true 【我用这个解决的】


  这样, 就能够正常发送邮件了。

回复

使用道具 举报

QQ|Archiver|手机版|小黑屋|Java321技术网   蜀ICP备15030946号-1

GMT+8, 2024-4-25 08:40 , Processed in 0.052258 second(s), 19 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表