一、Linux系统发送告警邮件脚本
背景:外部服务器
需求:
1. 安装mailx工具
2. 编辑mailx配置文件
3. 追加发送邮箱信息
4. 开启授权
5. 发送邮件测试
1. 安装mailx工具
yum install mailx -y
2. 编辑mailx配置文件
vim /etc/mail.rc
3. 追加以下内容
set [email protected] smtp=smtp.163.com
set [email protected] smtp-auth-password=授权码
set smtp-auth=login
4. 发送邮件测试
echo "this is test mail" |mail -s "monitor" 另一个邮箱地址(目标邮箱地址)
二、异常汇总
2.1. 异常信息
[root@ly-01 shell_scripts]# smtp-server: 535 Error: authentication failed
"/root/dead.letter" 11/310
. . . message not sent.
2.2. 开启授权码
## 2.3. 发送邮件测试
echo "this is test mail" |mail -s "monitor" 另一个邮箱地址(目标邮箱地址)