ubuntu使用mailx發送郵件

關閉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

  1. set from=xxx@163.com  
  2. set smtp=smtp.163.com  
  3. set smtp-auth-user=xxx@163.com  
  4. set smtp-auth-password=123456  
  5. set smtp-auth=login  


如果配置端口則


[html] view plain copy

  1. set from="xxx@163.com"  
  2. set smtp="smtps://smtp.163.com:465"  
  3. set smtp-auth-user="xxxm@163.com"  
  4. set smtp-auth-password="123456"  
  5. set smtp-auth=login  


或者


[html] view plain copy

  1. set from="xxx@163.com"  
  2. set smtp="smtps://smtp.163.com:465"  
  3. set smtp-auth-user="xxxm@163.com"  
  4. set smtp-auth-password="123456"  
  5. set smtp-auth=login  




注:以上三種配置都可以嘗試



3、發送

echo 'this is test' | mail -s "test email." [email protected]


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章