关闭sendmail或者postfix
service sendmail stop
service postfix stop
1、安装heirloom-mailx
apt install heirloom-mailx
2、配置外部SMTP
我的ECS是Ubuntu16.04 ,配置文件为/etc/s-nail.rc,把下面几行放置在最后
如果不配置端口发送可以使用
[html] view plain copy
- set from=xxx@163.com
- set smtp=smtp.163.com
- set smtp-auth-user=xxx@163.com
- set smtp-auth-password=123456
- set smtp-auth=login
如果配置端口则
[html] view plain copy
- set from="xxx@163.com"
- set smtp="smtps://smtp.163.com:465"
- set smtp-auth-user="xxxm@163.com"
- set smtp-auth-password="123456"
- set smtp-auth=login
或者
[html] view plain copy
- set from="xxx@163.com"
- set smtp="smtps://smtp.163.com:465"
- set smtp-auth-user="xxxm@163.com"
- set smtp-auth-password="123456"
- set smtp-auth=login
注:以上三种配置都可以尝试
3、发送
echo 'this is test' | mail -s "test email." 123@qq.com