Install and use mutt mail client and configure mail alert function under Linux

Time:2020-1-17

0. Before the official installation of mutt
Check the two security components first.
OPENSSL:

Copy code

The code is as follows:

OpenSSL version – a ා check the installation and version information

SASL (the system generally has its own):

Copy code

The code is as follows:

rpm -qa | grep sasl

Query as follows:
cyrus-sasl-gssapi-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-plain-2.1.23-15.el6_6.2.x86_64
cyrus-sasl-2.1.23-15.el6_6.2.x86_64
If SASL is not running, start it first:

Copy code

The code is as follows:

/etc/init.d/saslauthd start

It is better to join the self starting project:

Copy code

The code is as follows:

chkconfig saslauthd on

Because security authentication is required when sending email.

1, installation
Download the latest version on the official website.

Copy code

The code is as follows:

#Unzip and enter the mutt directory
cd /root/mutt-1.6.0
Compile:
./configure –prefix=/usr/local/mutt –enable-pop –enable-smtp –with-ssl –with-sasl
Explanation of Lei
–Enable pop enable pop
–Enable SMTP enable SMTP
–With SSL — with SASL with the above protocol enabled, you must use more secure encryption

PS: because the test account I use is QQ mail. When I use the SMTP protocol for QQ mail, I need to use SSL security connection. When I use the security connection in MUTT, I need to use SASL encryption. Therefore, the above two security components must be added when compiling and installing. Otherwise, “SMTP authentication requirements SASL” or another SSL related error will appear when sending mail.

Copy code

The code is as follows:

Installation
make && make install

2. Basic usage of mutt
Using mutt to send email is very convenient. It is a text mode email management program, which provides a full screen operation interface. Only one command is needed to send or batch send mail:

Copy code

The code is as follows:

Mutt [- hnprvxz] [- a < File >] [- B < address >] [- C < address >] [- f < mail file >] [- f < profile >] [- H < mail draft >] [- I < File >] [- M < type >] [- s < subject >] [mail address]

Here are the parameters:
-A < File > add additional files to the message.
-B < address > specifies the recipient address of the confidential copy.
-C < address > specifies the recipient address of the copy.
-F < mail file > specifies the mail file to load.
-F < configuration file > specifies the setup file for the mutt program without reading the default. Muttrc file.
-H displays help.
-H < e-mail draft > send the specified e-mail draft.
-I < File > inserts the specified file into the message body.
-M < type > specifies the default mail mailbox type.
-N do not read the program cultivation file (/ etc / muttrc).
-P after editing a message in mutt and you do not want to send it out immediately, you can postpone sending the message.
-R opens the mail file read-only.
-S < subject > specifies the subject of the message.
-V displays the version information for mutt and the parameters given when the file was originally compiled.
-X simulates how mailx is edited.
-When Z is used with the – f parameter, Mutt is not started if there is no mail in the mail file.
It is convenient to use mutt on the basis of mastering these. Next, we will introduce the subject of this article and use its email alert function:

3. Configure mail alert feature
Method 1:
After installation, copy a copy of the configuration file muttrc to / root /. Muttrc of / usr / local / mutt / etc / under the installation directory. You can also modify the configuration file directly, and set the path of the read configuration file to the safe directory, so there is no need to copy it.
Default settings:

Copy code

The code is as follows:

set alias_file=”~/.muttrc”

Method 2:

Copy code

The code is as follows:

cat /usr/local/mutt/etc/Muttrc | grep -v ^# | grep -v ^$ > ~/.muttrc

In this way, you can get the default profile information.
After installation, we only need to set the following information:

Copy code

The code is as follows:

Set folder = “. / mail” ා set up your local inbox, and you will be prompted if you don’t set up to send mail
Set from = “[email protected]” ා set sender address
Set realName = “Zhang San” ා sender’s name
Set SMTP? Pass = “9999”? Password
Set smtp_url = “SMTP: / / [email protected]: 465 / ා sender account and mail host information, QQ mailbox must use secure connection
Set use? Envelope? From = yes? Use custom sender mailbox
Set use? From = yes? Use custom sender name

4, test
The syntax of sending email in mutt-1.6 is slightly different from that in 1.4. The specific commands are as follows:
Mutt – s “title use” – A / usr / local / mutt / content.txt — [email protected] < / root / 1
Explain
-S message title
-a accessories
–Keep up with the recipient’s information
< the body content of the email is followed, which can also be given in the form of echo XXX. As follows:

Copy code

The code is as follows:

Echo xxx| mutt – s “title use” – A / usr / local / mutt / content.txt — [email protected]

See, without cooperation with other software, Mutt can send e-mail independently. Of course, there is no problem in receiving, but there is no need to alarm the e-mail.
One of the error messages:

Copy code

The code is as follows:

[[email protected] mutt]# echo “Hello” | mutt -s “Title” — [email protected]

TLSv1.2 connection using TLSv1/SSLv3 (AES256-SHA256)
SMTP authentication requires SASL
Could not send the message.
This is authentication failure.
Send successful message:

Copy code

The code is as follows:

[[email protected] mutt]# echo “Hello3” | mutt -s “Title” — [email protected]

TLSv1.2 connection using TLSv1/SSLv3 (AES256-SHA256)