ubuntu18.04 安装heirloom-mailx 通过外部SMTP服务器发送邮件

小伙伴们可以自行加入到监控脚本里面,可以节省一点维护时间。

一、配置软件源

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

结果:
在这里插入图片描述

参考链接:

猜你喜欢

转载自blog.csdn.net/qq_36588424/article/details/109616873