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

配置软件源
ubuntu18.04上无法直接安装heirloom-mailx,需要添加软件源

sudo vi /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.qq.com:465"
set smtp-auth-user="[email protected]"
set smtp-auth-password="ahkphxxabcbshabbga"
set smtp-auth=login
注意:1.第四行password是指的QQ邮箱授权码,不是密码,QQ邮箱授权码获取可以查看相关文章:https://jingyan.baidu.com/article/fedf0737af2b4035ac8977ea.html

   2.from 和 smtp-auth-user邮箱要一致

测试
echo "邮件内容" | s-nail -s "邮件主题" [email protected]
或者

s-nail -s "邮件主题" [email protected] < result.txt

原文链接:https://blog.csdn.net/mdx20072419/article/details/103901254

猜你喜欢

转载自www.cnblogs.com/daofaziran/p/12403910.html
今日推荐