centos可经过修改配置文件以使用外部SMTP服务器,达到不使用sendmail而用外部的smtp服务器发送邮件的目的,shell
操做以下:centos
1、安装mailx与sendmailbash
# yum -y install mailx # yum -y install sendmail # /etc/init.d/sendmail start # chkconfig sendmail on
2、配置发送邮箱的SMPT服务服务器
3、编辑邮件配置文件/etc/mail.rc,添加外部邮件认证信息测试
# vi /etc/mail.rc set from=xxx@163.com smtp=smtp.163.com set smtp-auth-user=xx@163.com smtp-auth-password=xxx smtp-auth=login
4、测试邮件发送spa
mail -s "`date +%F-%T`" xxx@sohu.com </root/messages.txt
5、配置计划任务的时候须要将邮件发送信息写入到shell脚本中code
[root@localhost]# cat sendmail.sh #!/bin/bash cat /root/crawler/Crawler_SecInfoLog/"`date +%F`_Crawler_SecInfoLog.txt" | mail -s "爬虫预警(`date +%F`)" 收信者@163.com