centos6.6 使用sendmail 备份日志发送邮件

一、环境描述

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,如需转载请自行联系原作者
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值