事情的起因是为了对服务器上的应用做一个监控预警。网上看了一堆shell发邮件的方案,文章内容大同小异,并没有解决我的实质问题。
参考:https://blog.csdn.net/just_shunjian/article/details/78677054
操作对象
Ubuntu 16.04
1.照攻略安装工具包 heirloom-mailx
apt install heirloom-mailx
2.修改配置文件为/etc/s-nail.rc
在最后添加
set from=xxx@163.com
set smtp=smtp.163.comset smtp-auth-user=xxx@163.com
set smtp-auth-password=123456 (这个是第三方登陆码 !!)
set smtp-auth=login
3.落坑,开始测试
mailx -s "hello" ***@qq.com
发现一直无法连通stmp服务器。
4.各种排查163邮箱设置,把IMAP/SMTP/POP3全都开通了,仍然没法解决问题。
尝试/etc/s-nail.rc 配置项改变
set smtp="smtps://smtp.163.com:465"
问题终于解决,邮件能成功发送