停止服务: 卸载掉Cent OS自带的sendmail
# /etc/init.d/sendmail stop
取消自动启动:
# chkconfig –levels 345 off sendmail
卸载sendmail:
# yum remove sendmail
卸载postfix 卸载掉Cent OS自带的postfix
# rpm -e –nodeps postfix
重新安装postfix
# yum -y install postfix
←
在线安装Postfix
[root@sample ~]# vi /etc/postfix/main.cf
←
编辑Postfix的配置文件
#myhostname = host.domain.tld
←
找到此行,将等号后面的部分改写为主机名
↓
myhostname = sample.centospub.com
←
变为此状态,设置系统的主机名
#mydomain = domain.tld
←
找到此行,将等号后面的部分改写为域名
↓
mydomain = centospub.com
←
变为此状态,设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)
#myorigin = $mydomain
←
找到此行,将行首的#去掉
↓
myorigin = $mydomain
←
变为此状态,将发信地址“@”后面的部分设置为域名(非系统主机名)
inet_interfaces = localhost
←
找到此行,将“localhost”改为“all”
↓
inet_interfaces = all
←
变为此状态,接受来自所有网络的请求
mydestination = $myhostname, localhost.$mydomain, localhost
←
找到此行,在行为添加“$mydomain”
↓
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
←
变为此状态,指定发给本地邮件的域名
#relay_domains = $mydestination
←
找到此行,将行首的#去掉
↓
relay_domains = $mydestination
←
变为此状态,定义允许转发的域名
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
←
找到此行,依照自己的内网情况修改
↓
mynetworks = 168.100.189.0/28, 127.0.0.0/8
←
变为此状态,指定内网和本地的IP地址范围,IP地址根据自己的环境配置
[root@sample ~]# alternatives –config mta
←
设置默认MTA
There are 2 programs which provide ‘mta’.
Selection Command
———————————————–
*+ 1 /usr/sbin/sendmail.sendmail
← 当前状态:sendmail为默认MTA
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2 ←
在这里输入2,使Postfix成为默认MTA
[root@sample ~]# chkconfig postfix on
←
将Postfix设置为自启动
[root@sample ~]# chkconfig –list postfix
←
确认Postfix服务状态
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
←
确认2~5为on的状态就OK
[root@sample ~]# /etc/rc.d/init.d/postfix start
←
启动Postfix
Starting postfix: [ OK
AMH下添加防火墙端口 原创:有客帮 http://www.ykit.cn 转载的请保留 谢谢
-A INPUT -p tcp -m tcp –dport 25 -j ACCEPT
PHP.ini修改
# vi /etc/php.ini
默认:
sendmail_path = /usr/sbin/sendmail -t -i
修改为
sendmail_path = /usr/sbin/sendmail.postfix -t -i
ESC键返回
Shift+:
wq保存
重启服务器,DZ下的PHP函数就可以发邮件了
原创:有客帮 http://www.ykit.cn 转载的请保留 谢谢
还请管理员手下留情不要删除我网站的链接 万分感谢
因为我就一个站,安全模式什么的我用不到,我的DZ现在可以直接PHP发送注册邮件了
安装成功的回个帖支持下吧!