在命令行里发邮件(Ubuntu)

(Ubuntu) Send email from Terminal using Gmail or your domain.
本文介绍如何在命令行里通过Gmail或者你自己的域名(需要你有Google Apps)发邮件,我在Ubuntu 10.10下测试通过。

(1)安装ssmtp

(2)之后配置/etc/ssmtp/ssmtp.conf如下:

root=YOUR_EMAIL@gmail.com
mailhub=smtp.gmail.com:465
rewriteDomain=gmail.com
AuthUser=YOUR_GMAIL_USERNAME # (without @gmail.com)
AuthPass=YOUR_GMAIL_PASSWORD
FromLineOverride=YES
UseTLS=YES

特别要注意的是rewriteDomain=后面不能用包括用户名,比如root@abc.com是不允许的,但abc.com是允许的

(3)测试
以下两种方法都可以发邮件:
echo “email content” | mail -s “email subject” me@zhanxw.com
echo “email content from mutt” | mutt -s “email subject” -a ‘content.txt’ — me@zhanxw.com

主要参考翻译自:
User Gmail to Send Email

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.