使用465端口加密发邮件 使用465端口加密发邮件

使用465端口加密发邮件

 
 

1、问题描述

今天因为服务需求,须要服务器须要发送邮件;可是不论用什么办法,发送邮件老是失败;最终发现缘由:阿里云实例服务器默认禁止了25端口;html

阿里云回复:vim

  因为国际与国内均对垃圾邮件进行严格管控,我国《互联网信息服务管理办法》、《中国互联网协会反垃圾邮件规范》均对垃圾邮件进行说明与管理规范。 鉴于服务器25端口被大量垃圾邮件充斥,严重影响广大用户正常使用。为了共同维护良好的网络环境,自即日起阿里云新购服务器再也不提供25端口邮件服务, 建议您尝试使用465加密端口发送邮件。服务器

因此研究了一下465端口发送邮件网络

 

2、使用465端口加密发送邮件

一、关闭其它的邮件工具

[root@along ~]# systemctl stop sendmail
[root@along ~]# systemctl stop postfix工具

二、安装mailx

[root@along ~]# yum install mailxpost

三、开启smtp

 在任何邮箱平台中开启smtp,开启后会获得一个受权码,这个受权码就代替了密码(自行去邮箱开启)。我使用的是163邮箱测试

四、请求数字证书(这里用的163邮箱,因此向163请求证书)

[root@along ~]# mkdir .certs阿里云

[root@along ~]# echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /root/.certs/163.crt加密

[root@along ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d /root/.certs -i /root/.certs/163.crturl

[root@along ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d /root/.certs -i /root/.certs/163.crt

[root@along ~]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d /root/.certs/./ -i /root/.certs/163.crt

Notice: Trust flag u is set automatically if the private key is present.

[root@along ~]# ls /root/.certs/

163.crt  cert8.db  key3.db  secmod.db

[root@along ~]# certutil -L -d /root/.certs

Certificate Nickname                                         Trust Attributes

                                                             SSL,S/MIME,JAR/XPI

 

GeoTrust SSL CA                                              P,P,P

 

五、配置/etc/mail.rc

[root@along ~]# vim /etc/mail.rc

set from=xxx@163.com #以前设置好的邮箱地址
set smtp="smtps://smtp.163.com:465" #邮件服务器
set smtp-auth-user=xxx@163.com #以前设置好的邮箱地址
set smtp-auth-password=xxxx #受权码
set smtp-auth=login #默认login便可
set ssl-verify=ignore #ssl认证方式
set nss-config-dir=/root/.certs #证书所在目录

 

六、发送邮件测试

[root@along ~]# echo "邮件正文" | mail -s "邮件主题" xxx@qq.com

邮件发送成功

相关文章
相关标签/搜索