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