前置条件:开启邮箱的 POP3/SMTP/IMAP 服务
1.修改/etc/mail.rc
vim /etc/mail.rc
在文件尾部添加这些内容
设置126邮箱
set from=“邮箱账号”@126.com
set smtp=smtp.126.com
set smtp-auth-user=“邮箱账号”@126.com
set smtp-auth-password=“代理授权码”
set smtp-auth=login
set from=“邮箱账号”@126.com
set smtp=smtp.126.com
set smtp-auth-user=“邮箱账号”@126.com
set smtp-auth-password=“代理授权码”
set smtp-auth=login
设置163邮箱
set from=“邮箱账号”@163.com
set smtp=smtp.163.com
set smtp-auth-user=“邮箱账号”@163.com
set smtp-auth-password=“代理授权码”
set smtp-auth=login
set from=“邮箱账号”@163.com
set smtp=smtp.163.com
set smtp-auth-user=“邮箱账号”@163.com
set smtp-auth-password=“代理授权码”
set smtp-auth=login
2.设置完成后 重启邮件
systemctl restart postfix
systemctl restart mailx
systemctl restart postfix
systemctl restart mailx
3.向邮箱发送测试邮件
echo "测试文字"| mail -s "邮件主题" “邮箱账号”@qq.com
echo "测试文字"| mail -s "邮件主题" “邮箱账号”@126.com
echo "测试文字"| mail -s "邮件主题" “邮箱账号”@qq.com
echo "测试文字"| mail -s "邮件主题" “邮箱账号”@126.com
4.登录邮箱查看接受的邮件