centos配置邮箱服务

1、安装邮箱服务

yum -y install sendmail mailx

2、修改配置

set smtp=smtps://smtp.163.com
set from=aaa@aaa.com   #发送方
set smtp-auth-user=aaa@aaa.com #发送方用户名
set smtp-auth-password=*********  #密码(非邮箱登录密码)或者密钥
set nss-config-dir=/root/.certs     #证书位置
set ssl-verify=ignore
set smtp-auth=login

3、生成证书文件:
顺序执行如下命令即可生成证书:

echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
certutil -L -d /root/.certs

生成证书时,根据邮件服务器的不同可以自己调整

4、为了防止出现前文所说的发送邮件警告提示,还需要进入邮箱 SSL 证书存放目录 /root/.certs 里执行如下命令

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

5、可以发送一封邮箱测试一下

echo date | mailx -s "data" -a "/root/a.txt" 123456@qq.com

mailx只支持单个附件发送,如果需要发送多个,可以压缩成文件

posted @ 2024-07-30 09:20  大司徒  阅读(14)  评论(0编辑  收藏  举报