阿里云服务器上用465端口发送邮件

第一步:安装mailx邮箱服务器

yum -y install mailx

第二步:在mailx配置文件里添加用户名,密码。mailx的配置文件是/etc/mail.rc这个文件。

set ssl-verify=ignore                                ###   启用证书
set nss-config-dir=/root/.certs                      ###   证书存放的位置
set from="[email protected]"                      ###   邮箱
set smtp="smtps://smtp.163.com:465"                  ###   邮箱服务器地址
set smtp-auth-user=sj9456478719@163.com              ###   邮箱
set smtp-auth-password=xxxxxxxxxxxxxx                ###   邮箱授权码(不是邮箱登录密码,不知道的话自己上去开通)set smpt-auth=login                                  ###   启用自动连接登录,就是发送邮件的时候自动连接到163服务器帮你发送邮件

第三步:既然要用到证书,那我们还得在163的服务器上申请一个证书。。证书名字自己定义(我这里命令为163.crt

mkdir -p /root/.certs/                                        ###    证书存放位置
cd /root/.certs
###下面这几条命令每一条我也不是太明白,我只知道生成了证书和证书文件,和启用的证书!
echo -n |openssl s_client -connect smtp.163.com:465 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >163.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i 163.crt
certutil -L -d /root/.certs

这样就可以通过465的邮箱发送邮件了!!下面我们就来验证一下是否能发送邮件吧!

echo "邮件正文" | mail -s "这是真的可以发送邮件了哦" [email protected]

猜你喜欢

转载自www.cnblogs.com/yeyu1314/p/10167944.html
今日推荐