一、环境描述
1
2
3
|
[root@mysql-121 ~]
# head -n1 /etc/issue
CentOS release 6.6 (Final)
[root@mysql-121 ~]
#
|
二、安装步骤
1.安装sendmail服务器
1
2
3
|
[root@mysql-121 ~]
# yum install sendmail -y
[root@mysql-121 ~]
# service sendmail start
[root@mysql-121 ~]
# service sendmail status
|
2.在/etc/mail.rc文件中添加发件人的邮箱认证信息
1
2
3
4
5
6
7
|
vi
/etc/mail
.rc
######add below#############
set
from=xxx@163.com
set
smtp=smtp.163.com
set
smtp-auth-user=xxx
set
smtp-auth-password=xxxxx
set
smtp-auth=login
|
3.邮件发送测试、可以发送到多个邮箱,带附件
1
|
echo
"Test using xxx@163.com to send email "
| mail -a
/root/dbbackup
.log -s
"This email from Linux"
xxxx@139.com xxxx@qq.com
|
三、问题处理
1.sendmail 启动慢,需要大概3分钟
1
2
3
4
5
|
[root@mysql-121 mail]
# service sendmail stop
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
[root@mysql-121 mail]
# service sendmail start
Starting sendmail: .....卡在这里几分钟
|
原始配置:
1
2
3
4
5
|
[root@mysql-121 ~]
# more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 mysql-121
# added by Apache Friends XAMPP
192.168.80.121 mysql-121
|
修改后配置
1
2
3
4
5
|
vi
/etc/hosts
127.0.0.1 localhost localhost.localdomain mysql-121
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 mysql-121
# added by Apache Friends XAMPP
192.168.80.121 mysql-121
|
重启,秒级别
1
2
3
4
5
|
[root@mysql-121 ~]
# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
|
2.sendmail和postfix 冲突
1
2
3
|
[root@mysql-121 ~]
# service sendmail status
sendmail dead but subsys locked
sm-client (pid 22112) is running...
|
检查postfix服务的状态
1
2
|
[root@mysql-121 ~]
#service postfix status
master (pid 1777) is running...
|
停止postfix服务
1
2
|
[root@mysql-121 ~]
#service postfix stop
Shutting down postfix: [ OK ]
|
重新启动sendmail服务
1
2
3
4
5
|
[root@mysql-121 ~]
# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client:
|
禁用postfix在reboot后自动启动
1
2
3
4
5
6
|
[root@mysql-121 ~]
# chkconfig --list |grep postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mysql-121 ~]
# chkconfig postfix off
[root@mysql-121 ~]
# chkconfig --list|grep postfix
postfix 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@mysql-121 ~]
#
|
本文转自 roidba 51CTO博客,原文链接:http://blog.51cto.com/roidba/1880841,如需转载请自行联系原作者