首页 > 技术文章 > linux安装mail并发邮件到163邮箱

Bathing 2021-08-26 14:48 原文

1. 开启smtp服务
登录网易邮箱 https://mail.163.com/ 开启服务,设置授权密码并记录
2. 安装
[root@localhost ~]# yum install mailx
 
3.修改配置文件
[root@localhost ~]# vim /etc/mail.rc #修改如下
set from=xxxx@163.com
set smtp=smtps://smtp.163.com:465
set smtp-auth-user=xxxx@163.com
set smtp-auth-password=xxxxx
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs
 
--说明
from:对方收到邮件时显示的发件人
smtp:指定第三方发邮件的smtp服务器地址,云服务器必须使用465端口默认25端口被禁用
set smtp-auth-user:第三方发邮件的用户名
set smtp-auth-password:  邮箱的授权码注意不是密码
smtp-auth:SMTP的认证方式,默认是login,也可以改成CRAM-MD5或PLAIN方式
set ssl-verify: 使用证书,也就是用465端口
nss-config-dir: 证书存放的目录
 
4. 生成证书
[root@localhost ~]# mkdir -p /root/.certs/
[root@localhost ~]# echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt
 
5. 添加证书到证书数据库
[root@localhost ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
[root@localhost ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
 
6. 信任证书
[root@localhost ~]# cd /root/.certs/
[root@localhost ~]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i 163.crt
 
7. 发送邮件
[root@localhost ~]# mail -s "标题" 邮箱

推荐阅读