有一天,我发现报警邮件没发出来,公司以为是监控除了故障,好死不死查了大半天,却是网易smtp的25端口给封了。咨询过后说是可以使用ssl端口,“那好吧,学谁不好非要学阿里云,封就封吧,封之前也不说一声”。该抱怨的抱怨完了,还是得解决啊,还好也算简单。方法分两步,记录如下
【资料图】
修改mail.rc文件
vim /etc/mail.rc ###添加以下内容 set from="xxxx@163.com" set smtp="smtps://smtp.163.com:465" set smtp-auth-user="xxxx用户名" set smtp-auth-password="smtp代理密码,不一定是你的邮箱密码" set smtp-auth=login set nss-config-dir=/etc/mail.rc_ssl.crt set smtp-user-starttls set ssl-verify=ignore
包含一些文件
在/etc下新建mail.rc_ssl.crt目录。并在目录下增加Firefox浏览器*.db文件(cert8.db、key3.db、secmod.db)以支持SSL的方式发送邮件。如果你的电脑上装有firefox,这些文件的获取方式如下:
windows可以在%userProfile%\AppData\Roaming\Mozilla\Firefox\Profiles\xxx.defaultLinux在~/.mozilla/firefox/xxx.default目录下获取*.db文件当然也可以直接下载:https://dn-zhangguoli.qbox.me/mail.rc_ssl.crt.zip
查看一下,效果如下
[root@xuyanlinux mail.rc_ssl.crt]# pwd/etc/mail.rc_ssl.crt[root@xuyanlinux mail.rc_ssl.crt]# lscert8.db cert9.db key3.db key4.db secmod.db
发邮件验证
[root@xuyanlinux mail.rc_ssl.crt]# echo "this is a test mail from xuyanlinux"|mail -s "apiweb" xxxx0@163.com [root@xuyanlinux mail.rc_ssl.crt]# Error in certificate: Peer"s certificate issuer is not recognized.^C[root@xuyanlinux mail.rc_ssl.crt]# echo "this is the G3 test mail from xuyanlinux"|mail -v -s "apiweb" xxxx@163.com Resolving host smtp.163.com . . . done.Connecting to 220.181.12.18:465 . . . connected.Error in certificate: Peer"s certificate issuer is not recognized.Comparing DNS name: "*.163.com"SSL parameters: cipher=AES-256-GCM, keysize=256, secretkeysize=256,issuer=CN=GeoTrust RSA CA 2018,OU=www.digicert.com,O=DigiCert Inc,C=USsubject=CN=*.163.com,OU=Game Dep.,O="NetEase (Hangzhou) Network Co.,Ltd",L=Hangzhou,ST=Zhejiang,C=CN220 163.com Anti-spam GT for Coremail System (163com[20141201])>>> EHLO xuyanlinux250-mail250-PIPELINING250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2Ur4xf1hUCa0xDrUUUUj250-STARTTLS250 8BITMIME>>> AUTH LOGIN334 dXNlcm5hbWU6>>> MTg2Njk3ODUyODA=334 UGFzc3dvcmQ6>>> aHVodW5pYW5nNTIx235 Authentication successful>>> MAIL FROM:<18669785280@163.com>250 Mail OK>>> RCPT TO:<18669785280@163.com>250 Mail OK>>> DATA354 End data with.>>> .250 Mail OK queued as smtp14,EsCowAAnfNaxQ25ccO3BGg--.34595S2 1550730161>>> QUIT221 Bye
如上,发了两封邮件,有报错,但其实邮件已经发送成功了。