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]


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