ubuntu下使用mutt和msmtp發送郵件的簡單配置

來源:互聯網
上載者:User
sudo apt-get install mutt

 

sudo apt-get install msmtp

安裝好了這兩個包之後,就是進行相關設定檔的配置了:

 

首先配置 mutt,系統全域設定設定檔在 /etc/Muttrc,如果使用某個系統使用者,可以在~/.muttc中設定,沒有該檔案,就自己建立。

vi .muttrc

1    set sendmail="/usr/bin/msmtp"
2    set use_from=yes
3    set realname="zhxia"
4    set from=zhenghongxia@anjuke.com
5    set envelope_from=yes

 

 

接著,配置msmtp

 

建立 ~/.msmtprc 和 ~/.msmtp.log,分別為設定檔和記錄檔

vi .msmtprc

1 account default
2 host smtp.corpease.net
3 from zhenghongxia@anjuke.com
4 auth plain
5 user zhenghongxia@anjuke.com
6 password xxxxxxx
7 logfile ~/.msmtp.log

 

由於password是明文,所以需要修改此檔案的存取權限

chmod 600 .msmtprc 

同時建立 記錄檔 touch ~/.msmtp.log

 

做完了以上的配置之後,可以進行郵件的發送測試了:

 

查看SMTP伺服器是否支援認證的TLS加密:

 

1 zhxia@zhxia-Desktop:~$ msmtp --host=smtp.corpease.net --serverinfo
2 SMTP server at smtp.corpease.net (mail3.corpease.net [61.145.121.45]), port 25:
3     corpease.net Anti-spam GT for Coremail System (corpease[20100527])
4 Capabilities:
5     PIPELINING:
6         Support for command grouping for faster transmission
7     AUTH:
8         Supported authentication methods:
9         PLAIN LOGIN

 

 發送郵件測試:

1 echo "hello world" | mutt -s "title" 252578390@qq.com

 一般情況下,均可已正常內送郵件。

 下面是一個比較完整的發送郵件樣本:

 

1 echo "hello" | mutt -s "title" 252578390@qq.com,zhenghong-xia@163.com -c 402714871@qq.com -a /tmp/ip.tmp

 發送給多人,抄送,添加附件

 

address="zhenghongxia@anjuke.com"
echo $content|mutt  -s "${subject}" -e 'set content_type="text/html"' -e 'send-hook . "my_hdr  X-Priority: 1"' $address

 發送郵件時設定郵件的文本類型為:html格式,郵件的等級為:重要

參考文章:

 http://hi.baidu.com/realasking/blog/item/10c1c3d346be6cd2a9ec9adc.html

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.