mutt命令执行了却发送不了邮件, 搜索了一会才明白原来是mutt需要一个发信的程序, msmtp刚好是一个不错的选择.
1. apt-get install mutt msmtp
(安装过程中会弹出Postfix的配置向导,这一步选择No Configuration即可)
2. ~/.muttrc & ~/.msmtprc 是当前用户的配置信息, 如果不加则会使用全局配置: /etc/Muttrc (msmtprc暂时找不到该文件, 不知为何?)
3. vi ~/.muttrc
在最后加上:
set sendmail="/usr/bin/msmtp" set use_from=yes set realname="zhang_san" ##发件人名字 set from=zhang_san@abc.cn ##发件人地址 set envelope_from=yes
4. vi ~/.msmtprc, 然后修改此文件的权限为600
defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account freemail
host smtp.partner.outlook.cn
from chen_dong@abc.cn
auth on
user zhang_san@abc.cn
password XXXXXXX
logfile ~/.msmtp.log
account default : freemail
5. 测试
echo "hello world" | mutt -s "title" chen_dong@abc.cn
2015-9-1更新:
其实如果只是想实现发送邮件的功能, 则无需mutt的帮助, 通过msmtp -t receiver@abc.cn即可。
http://muttrcbuilder.org/
http://www.mutt.org/doc/manual/manual-6.html
以上两个网站和muttrc文件有关.
http://msmtp.sourceforge.net/doc/msmtprc.txt
以上这个网站是msmtprc的示例文件.
附上世纪互联版Office 365的SMTP信息:
chen@ubuntu1404:~$ msmtp --host=smtp.partner.outlook.cn --serverinfo --tls=on --tls-trust-file=/etc/ssl/certs/ca-certificates.crt SMTP server at smtp.partner.outlook.cn ([42.159.163.194]), port 25: SH2PR01CA024.partner.outlook.cn Microsoft ESMTP MAIL Service ready at Tue, 28 Jul 2015 00:00:44 +0000 TLS certificate information: Owner: Common Name: partner.outlook.cn Organization: Shanghai Blue Cloud Technology Co. Ltd Organizational unit: Office365 Locality: Shanghai State or Province: Shanghai Country: CN Issuer: Common Name: WoSign Class 3 OV Server CA G2 Organization: WoSign CA Limited Country: CN Validity: Activation time: Tue 14 Jul 2015 09:48:55 PM CST Expiration time: Fri 14 Jul 2017 09:48:55 PM CST Fingerprints: SHA1: B5:BB:23:D6:2B:8F:9E:A7:6A:CC:20:C4:FF:59:44:D2:0E:9B:62:64 MD5: 19:6E:82:6A:FB:7C:60:33:1A:8D:60:CC:ED:7F:82:33 Capabilities: SIZE 157286400: Maximum message size is 157286400 bytes = 150.00 MiB PIPELINING: Support for command grouping for faster transmission DSN: Support for Delivery Status Notifications STARTTLS: Support for TLS encryption via the STARTTLS command AUTH: Supported authentication methods: LOGIN