Install and configure msmtp and mutt in centos

Source: Internet
Author: User
Tags test email address vps ixwebhosting

I bought a VPs in China a month ago and learned about Linux from scratch while feeling the power of Linux. A few days ago, I accidentally failed to restart the VPs, And the Help Service Provider failed to retrieve the information. Because there was no backup and no data was found, I had to reinstall the system. When something went wrong, I realized the importance of backup. So I began to study backup, specifically automatic backup. The most widely circulated articles on the Internet are the method of sending email attachments with Mutt for backup. As you can see, you learned how to successfully use ixwebhosting on the host (the host of ixwebhosting also supports cron ).

You can return to your VPS today. After the sh script is written, the file is successfully packaged and the mutt command is executed, but the email cannot be sent. After searching for a while, I realized that mutt needed a mail program, and msmtp was a good choice. There are also a lot of articles on msmtp on the Internet. Below I will process the annotation results for several articles, hoping to be useful to new Linux users like me.

1. install and configure msmtp

1. Download and decompress msmtp

First use putty and other tools to log on to SSH

Wget http://downloads.sourceforge.net/msmtp/msmtp-1.4.16.tar.bz2? Modtime = 1217206451 & big_mirror = 0

Tar jxvf msmtp-1.4.16.tar.bz2

2. Installation

./Msmtp-1.4.16/configure -- prefix =/usr/local/msmtp

Make

Make install

Note that the directory marked in red is extracted to that directory. I don't know why Yum cannot be used for direct installation. An error is prompted.

3. Configure an msmtp account

Switch to, CD/usr/local/msmtp

Create folder etc, mkdir etc

Use VI to create a file and enter VI/usr/local/msmtp/etc/msmtprc. The edit content is as follows:

# Set default values for all following accounts.

Ults

Logfile/usr/local/msmtp. Log

# The SMTP server of the provider.

Account Test

# SMTP mail server address

Host smtp.qq.com

# Email sent

From xiaobaichi@i0554.com

AUTH LOGIN

# Email server Logon account

User xiaobaichi@i0554.com

# Email server login password

Password 123456

# Set a default account

Account default: Test

ESC, Shift +: Enter command mode, enter WQ, save and exit.

Because the password is a plaintext, we need to modify the CHMOD 600. msmtprc permission for this file.

4. Test

/Usr/local/msmtp/bin/msmtp youremail@test.com

Enter any character and press Ctrl + D to exit and check whether the email is received.

With logs set, you can go to/usr/local/msmtp. log to view the logs. The success or failure of sending emails will be recorded.

Ii. install and configure mutt

1. Mutt is installed by default in Linux, and centos is no exception.

You can use which mutt to view the mutt installation path. If not, use # Yum install mutt.

2. Edit the mutt configuration file

VI/etc/muttrc, edit the overall settings of mutt, and modify the following lines

Set From = "sending email address"

Set Sendmail = "/usr/local/msmtp/bin/msmtp"

Set use_from = Yes

Set realname = "sender"

Set Editor = "Vi"

It is recommended that the Sending address be the same as the account set by msmtp; otherwise, an error may occur.

VI ~ /. Muttrc: edit the settings in the root directory.

Set envelope_from = Yes

Set From = "sending email address"

Set realname = "sender"

Set use_from = Yes

3. Test whether mutt is valid.

Echo "test" | mutt-s "test" test email address

Echo "test" | mutt-s "my_first_test" yangcheng@i0554.com

Next we can use Mutt for email backup and other work. Combined with CRON, there are many functions that can be implemented.

Related Article

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.