Centos使用mailx465端口发送邮件

https://blog.whsir.com/post-2475.html

mailx默认25端口发送邮件,但是在一些云服务器中为了防止邮件滥发,往往都对25端口做了限制,所以此时就使用到加密的465端口了,本篇文章以qq邮箱为例来配置mailx,通过465端口发送邮件。

1、关闭其它的邮件工具

service sendmail stop
chkconfig sendmail off
service postfix stop
chkconfig postfix off

2、安装mailx

yum install mailx

3、首先在邮箱中开启smtp,开启后会得到一个授权码,这个授权码就代替了密码(自行去邮箱开启)。

4、请求数字证书(这里用的qq邮箱,所以向qq请求证书)

1、

mkdir ~/.certs

echo -n | openssl s_client -connect smtp.exmail.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt

 2、certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt

 3、certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt 

 4、certutil -L -d /root/.certs 
    
 5、certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt

5、配置/etc/mail.rc

set from=xxx@qq.com #之前设置好的邮箱地址

set smtp=smtps://smtp.qq.com:465 #邮件服务器

set smtp-auth-user=xxx@qq.com #之前设置好的邮箱地址

set smtp-auth-password=xxxx #授权码

set smtp-auth=login #默认login即可

set ssl-verify=ignore #ssl认证方式

set nss-config-dir=/root/.certs #证书所在目录

6、发送邮件测试

echo "邮件正文" | mail -s "邮件主题" xxx@126.com

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值