一、获取163邮箱授权码
1、登录163邮箱:进入你的163邮箱账户,点击设置图标。
2、开启SMTP服务:进入“POP3/SMTP/IMAP”选项,确保SMTP服务已开启。

3、设置客户端授权码:在“客户端授权密码”中设置或重置授权码,并保存。
二、安装mailx服务
1、使用yum命令安装:
yum y install mailx
三、配置smtp设置
1、编辑配置文件:
vim /etc/mail.rc
2、添加以下内容:
set from=your@163.com set smtp=smtps://smtp.163.com:465 set smtpauthuser=your@163.com set smtpauthpassword=your_authorization_code set smtpauth=login set sslverify=ignore set nssconfigdir=/root/.certs
请将your@163.com替换为你的163邮箱地址,并将your_authorization_code替换为你的授权码。
四、下载163邮箱证书
1、创建证书目录:

mkdir p /root/.certs/
2、下载并保存证书:
echo n | openssl s_client connect smtp.163.com:465 | sed ne '/BEGIN CERTIFICATE/,/END CERTIFICATE/p' > ~/.certs/163.crt
3、导入证书:
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
五、测试发送邮件
1、测试发送邮件:
echo "这是邮件body" | mail s "这是邮件标题" xxx@qq.com
如果邮件发送成功,表示配置正确。
六、常见问题及解决方法
1、无法发送邮件:检查授权码是否正确,以及是否开启了SMTP服务。
2、邮件被退回:确认接收方邮箱未将发件人设置为黑名单。

通过以上步骤,你可以在CentOS 7系统上成功配置163邮箱客户端,用于发送邮件。
