1 yum install mailx
2 vi /etc/mail.rc //如果不存在,则编辑/etc/mail.rc
set from=公司企业QQ 邮箱
set smtp=smtp.exmail.qq.com
set smtp-auth-user=公司企业QQ 邮箱
set smtp-auth-password=密码
set smtp-auth=login
3 mailx -s "ss" [email protected] < ss.sh 发邮件测试
这里填写的邮箱地址可以和配置文件中填写的相同,也可以不同。
4 这里使用QQ 邮箱,163 邮箱也是也可以的。

ubuntu 16.04 
apt install heirloom-mailx

Ubuntu16.04 ,配置文件为/etc/s-nail.rc,把下面几行放置在最后

如果不配置端口发送可以使用

set from=QQ 企业邮箱 smtp=smtp.exmail.qq.com
set smtp-auth-user=QQ 企业邮箱 smtp-auth-password=邮箱密码
set smtp-auth=login

mailx -s "ss" QQ 企业邮箱 < /root/.profile