關閉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." [email protected]