mailx是邮件代理工具 并非邮箱服务器,配置指定邮件账号发送邮件!!!
邮件用户代理(MUA,Mail User Agent)
邮件传送代理(MTA,Mail Transport Agent)
邮件分发代理(MDA,Mail Deliver Agent)
1、安装
yum -y install mailx
2、修改配置文件 /etc/mail.rc
// 配置文件解释:
set from=xxx@126.com # 发送的邮件地址
set smtp=smtp.126.com # 发送邮件服务器
set smtp-auth-user=xxx@126.com # 发件人账号,一般情况下为邮件地址
set smtp-auth-password=xxx # 发件人密码
set smtp-auth=login # 邮件认证方式
//QQ生成授权码及配置文件内容:
[root@localhost ~]# tail -n 5 /etc/mail.rc
set from=1507341xx4@qq.com
set smtp=smtp.qq.com
set smtp-auth-user=1507341xx4@qq.com
set smtp-auth-password="xxxx"
set smtp-auth=login
//163生成授权码及配置文件内容:
[root@localhost ~]# tail -n 5 /etc/mail.rc
set from=qinzitenxxx@163.com
set smtp=smtp.163.com
set smtp-auth-user=qinzitenxxx@163.com
set smtp-auth-password="xxxx"
set smtp-auth=login
3、测试
echo `date '+%X-%x'` | mail -s "test" 17901685xx@qq.com