小伙伴们可以自行加入到监控脚本里面,可以节省一点维护时间。
一、配置软件源
unbuntu 18.04移除了heirloom-mailx,需要另外配置软件源
sudo vim /etc/apt/sources.list
加入:
deb http://cz.archive.ubuntu.com/ubuntu xenial main universe
二、安装heirloom-mailx
sudo apt-get update
sudo apt install heirloom-mailx
三、配置外部SMTP
Ubuntu18.04的配置文件为/etc/s-nail.rc,把下面几行放置在最后
set from="[email protected]"
set smtp="smtps://smtp.163.com:465"
set smtp-auth-user="[email protected]"
set smtp-auth-password="ahkphxxabcbshabbga"
set smtp-auth=login
注意:第四行password是指的邮箱授权码,不是密码,需要登录到邮箱官网查看。
四、测试
echo "邮件内容" | s-nail -s "邮件主题" [email protected]
或者:
s-nail -s "邮件主题" [email protected] < result.txt
结果:
参考链接: