课程地址:https://edu.51cto.com/course/15585.html
安装 mailx
作为运维工程师,我们经常需要编写一下自己的系统或者服务器监控脚本,通过监控脚本及时了解系统的状态,可以通过 mailx
工具将监控状态及时邮件通知运维人员。
$ yum install mailx -y
配置 /etc/mail.rc
配置/etc/mail.rc文件(账户信息是假的,不用试了)
#设置发件人名称
set [email protected]
#设置邮件服务器
set smtp=smtp.maksim.website
#填写自己邮箱地址
set [email protected]
#输入邮箱验证码
set smtp-auth-password=pfljngafoqaxecff
#smtp的认证方式,默认是login
set smtp-auth=login
常用命令
# 用管道符直接发送
$ echo “wuhs test” | mail -s “主题” [email protected]
# 用Enter.Enter发送
$ mail -s “主题” [email protected]
# 发送时显示详细信息
$ mail -v -s “主题” [email protected]
带附件发送
$ mail -v -a /path/filename -s “主题” [email protected]