阿里云ECS实例邮件发送不了的解决办法

云服务器 aliyun111com 459℃ 0评论

阿里云服务器:[活动地址]

购买可领取:[阿里云2000元代金券]

最近要做一个定时任务错误信息实时转发到邮件,由于用的阿里云服务器一直不成功,在网上找了下原因:

是因为阿里云服务器关闭了25端口,发送邮件才会显示链接超时,而且官方不允许打开该端口,而且大部分邮件都是通过25端口,在网上找了个还不错,以网易163邮箱为例,使用SSL下的465端口。

具体操作:

一、请求数字证书

mkdir -p /root/.certs/ ####创建目录,用来存放证书

echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > ~/.certs/163.crt ####向163请求证书

certutil -A -n “GeoTrust SSL CA” -t “C,,” -d ~/.certs -i ~/.certs/163.crt ####添加一个SSL证书到证书数据库中

certutil -A -n “GeoTrust Global CA” -t “C,,” -d ~/.certs -i ~/.certs/163.crt ####添加一个Global 证书到证书数据库中

certutil -L -d /root/.certs ####列出目录下证书

二、配置发件人

输入命令: vi /etc/mail.rc

配置如下

For Linux and BSD, this should be set.

set bsdcompat

set from=xxxxxx@163.com

set smtp=smtps://smtp.163.com:465

set smtp-auth-user=xxxxxx@163.com

set smtp-auth-password=xxxxxxx #此密码为第三方登录密码

set smtp-auth=login

set ssl-verify=ignore

set nss-config-dir=/root/.certs

三、测试
echo “test” | mail -s “zabbix” xxxxxxx@qq.com

登陆收件人邮箱查看
看似成功但是linux中报错:证书不被信任

四、解决最后一个问题—–证书不被信任

cd /root/.certs/

certutil -A -n “GeoTrust SSL CA – G3” -t “Pu,Pu,Pu” -d ./ -i 163.crt

成功标志:
Notice: Trust flag u is set automatically if the private key is present.

阿里云服务器:[活动地址]

购买可领取:[阿里云2000元代金券]

转载请注明:http://www.aliyun111.com » 阿里云ECS实例邮件发送不了的解决办法

喜欢 (0)or分享 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址