Linux Shell脚本专栏_Linux系统发送告警邮件脚本_02

一、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" 另一个邮箱地址(目标邮箱地址)

在这里插入图片描述

发布了858 篇原创文章 · 获赞 114 · 访问量 17万+

猜你喜欢

转载自blog.csdn.net/weixin_40816738/article/details/104475706