Simple configuration of sending mails using mutt and msmtp in ubuntu

Source: Internet
Author: User
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

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.