51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Centos使用mailx465端口发送邮件

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

1、关闭其它的邮件工具
service sendmail stop chkconfig sendmail off service postfix stop chkconfig postfix off

|---------|-----------------------------------------------------------------------------------------| | 1 2 3 4 | service sendmail stop chkconfig sendmail off service postfix stop chkconfig postfix off |

2、安装mailx
yum install mailx

|---|-------------------| | 1 | yum install mailx |

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

4、请求数字证书(这里用的qq邮箱,所以向qq请求证书)
mkdir -p /root/.certs/ echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i qq.crt certutil -L -d /root/.certs

|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 | mkdir -p /root/.certs/ echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i qq.crt certutil -L -d /root/.certs |

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 #证书所在目录

|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 | 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

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


赞(0)
未经允许不得转载:工具盒子 » Centos使用mailx465端口发送邮件