Could not connect to smtp host报错的解决方案

linux下服务器发送邮件报错:could not connect to smtp host

在网上找了很多方法,都未能解决,后来关闭selinux,问题解决。
原因分析:selinux默认阻止了apache向外的 socket 
解决方案:
第一种关闭selinux
[root@localhost /]# vi /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

将SELINUX=enforcing 改为 SELINUX=disabled

然后:reboot

第二种配置SELINUX:

[root@localhost /]# setsebool -P httpd_can_network_connect 1
[root@localhost /]# service httpd restart
[root@localhost /]# service network restart

转载请注明出处:怡然之乐 – FineYi

参考资料:Ryan’s Scraps

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注