linux发送邮件通知

由于监控系统要求,需要及时收到系统运行状态,发邮件是一个很好的方式

1, linux配置

首先要保证使用的邮箱(比如[email protected]) 开通了smtp服务,具体设置参考:https://blog.csdn.net/eyeofeagle/article/details/104295051

yum -y install  mailx

#配置邮件验证信息
cat >> /etc/mail.rc <<EOF
[root@eadage ~]# tail /etc/mail.rc
set [email protected] 
set smtp=smtp.126.com
set [email protected] 
set smtp-auth-password=aaaabbb123pass ##此处是邮箱授权码,不是登陆密码
set smtp-auth=login
set ssl-verify=ignore
EOF
source /etc/mail.rc

#发送邮件
echo asdf | mailx -s 'test' [email protected] [email protected]

2, 邮件查看

上面发送了一条信息给126邮箱, qq邮箱: 标题是test, 内容是asdf
在这里插入图片描述

发布了276 篇原创文章 · 获赞 37 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/eyeofeagle/article/details/104665935