Sudo apt-get install mutt
Sudo apt-get install msmtp
After the two packages are installed, configure the relevant configuration file:
First, configure mutt. The system sets the configuration file in/etc/Muttrc. If you use a system user ~ /. Muttc settings. If this file is not found, you can create it yourself.
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
Next, configure msmtp
Create ~ /. Msmtprc and ~ /. Msmtp. log, which are configuration files and log files respectively
Vi. msmtprc
1 account default
2 host smtp.corpease.net
3 from zhenghongxia@anjuke.com
4 auth plain
User zhenghongxia@anjuke.com
6 password xxxxxxx
7. logfile ~ /. Msmtp. log
Because the password is in plain text, you need to modify the access permission for this file.
Chmod 600. msmtprc
Simultaneously create log file touch ~ /. Msmtp. log
After completing the above configuration, you can test the mail sending:
Check whether the SMTP server supports authenticated TLS encryption:
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 [1, 20100527])
4 Capabilities:
5 PIPELINING:
6 Support for command grouping for faster transmission
7 AUTH:
8 Supported authentication methods:
9 PLAIN LOGIN
Test email sending:
1 echo "hello world" | mutt-s "title" 252578390@qq.com
Generally, emails can be normally received.
The following is a complete mail sending example:
1 echo "hello" | mutt-s "title" 252578390@qq.com, zhenghong-xia@163.com-c 402714871@qq.com-a/tmp/ip. tmp
Send to multiple users, CC, add attachments
Address = "zhenghongxia@anjuke.com"
Echo $ content | mutt-s "$ {subject}"-e 'set content_type = "text/html" '-e' send-hook. "my_hdr X-Priority: 1" '$ address
When sending an email, set the text type of the email to html, and the mail level to important.
References:
Http://hi.baidu.com/realasking/blog/item/10c1c3d346be6cd2a9ec9adc.html