Centos7配置163邮件服务并发送邮件

0.环境准备
修改hosts文件
127.0.0.1 localhost.localdomain localhost 主机名
127.0.0.1 主机名
 
1.需要用到的软件包:sendmail,mailx
两者直接用yum安装即可
    
yum -y install sendmail mailx
 
2.开启163邮箱smtp服务,设置授权码
 
3.配置mailx配置文件,直接在尾部加入配置
vi /eta/mail.rc
set from=xxx@163.com    #设置发件人,这个可以随意填写,建议和邮箱一致
set smtp=smtps://smtp.163.com:465    
set smtp-auth-user=xxx@163.com    #设置邮箱
set smtp-auth-password=xxx        #设置授权码
set smtp-auth=login                    
set nss-config-dir=/root/.certs/
set ssl-verify=ignore
 
4.配置证书
mkdir -p /root/.certs/
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
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.
 
5.启动服务,发送邮件
systemctl start sendmail
echo 内容 | mailx -s '标题' 接收人邮箱
 
注意!!
mailx -v 选项可以查看执行过程,对排错很有用!
 
posted @ 2019-04-20 09:38  daysomeon  阅读(484)  评论(0编辑  收藏  举报