我的博客
欢迎来到我的博客
bunny.icu

Linux发送邮件

Linux发送邮件

阿里云封禁了25端口,所以只能用SMTPS来发

下面已163邮箱为例

修改 smtp 配置文件

vim /etc/mail.rc

在文末添加

set from=[邮箱]
set smtp=smtps://smtp.163.com:465
set ssl-verify=ignore
set nss-config-dir=/root/.certs
set smtp-auth-user=[邮箱]
set smtp-auth-password=[授权码]
set smtp-auth=login

邮箱好像是不区分马消息的,授权码不是登录密码
然后,要使配置文件生效

source /etc/mail.rc

如果有ignorefwdretain报错,注释掉就好了

配置证书

mkdir /root/.certs
echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -L -d .certs
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/ -i ~/.certs/163.crt

这个过程应该是不会出问题的。

发送邮件

mail -v -s "[邮件主题]" [接收邮箱]

然后,会要求输入邮件内容,按Ctrl + D结束,就会发送了。

如果要发送内容比较复杂的邮件,可以参考下面Reference第2个

Reference

https://blog.csdn.net/ithomer/article/details/83744621

https://www.cnblogs.com/xiaoshi1991/archive/2012/09/20/2695061.html

https://blog.51cto.com/ityunwei2017/1713425

版权声明


本作品系原创, 转载须遵循 CC BY-NC-ND 4.0 许可协议
本文标题:Linux发送邮件
本文链接:https://www.bunny.icu/archives/1080

推荐文章

发表评论

textsms
account_circle
email

bunny.icu

Linux发送邮件
Linux发送邮件
扫描二维码继续阅读
2020-03-10