首页 > 其他 > 详细

使用465端口发送邮件

时间:2021-08-03 18:45:23      阅读:18      评论:0      收藏:0      [点我收藏+]

一、问题描述

最近由于业务需求,定位到服务发送邮件环节故障,服务器拒绝了25端口,改为mailx工具来进行邮件发送服务。

 

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

1 关闭其它的邮件工具

[root@test01 ~]# systemctl stop sendmail
[root@test01 ~]# systemctl stop postfix

 

2 安装mailx

[root@test01 ~]# yum -y install mailx

3 开启smtp

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

4 请求数字证书

(这里用的sina邮箱,所以向sina请求证书)

[root@test01 ~]# mkdir .certs

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

[root@test01 ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d /root/.certs -i /root/.certs/sina.crt

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

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

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

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

sina.crt cert8.db key3.db secmod.db

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

Certificate Nickname Trust Attributes

SSL,S/MIME,JAR/XPI

 
GeoTrust SSL CA P,P,P

 

5 配置/etc/mail.rc

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

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

6 发送邮件测试

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

邮件发送成功

使用465端口发送邮件

原文:https://www.cnblogs.com/alisapine/p/15095184.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!