Linux can be sent directly by mail commands, but the sender is [email protected], if the machine does not have an extranet DNS, others can not reply. At this point, it is important to have a mail-sending program that can use the free e-mail service. MSMTP is a program like this.
#1, download the source package
wget http://sourceforge.net/projects/msmtp/files/msmtp/1.4.31/msmtp-1.4.31.tar.bz2/download
#2, unzip
TAR-JXVF msmtp-1.4.31.tar.bz2 && CD msmtp-1.4.31
#build and install
./configure--prefix=/usr/local/msmtp && make && make install
#link To/usr/bin
Ln-s/USR/LOCAL/MSMTP/BIN/MSMTP/USR/BIN/MSMTP
#3, new configuration file for Msmtp
Mkdir/usr/local/msmtp/etc
mkdir/var/log/msmtp/
Vim/usr/local/msmtp/etc/msmtprc
#4, enter the following:
# Set default values for all following accounts.
Defaults
Logfile/var/log/msmtp/msmtp.log
# The SMTP server of the provider.
Account 163
# SMTP mail server address
Host Smtp.163.com
# e-Mail Email
From [email protected]
Auth Login
# Mail Server login account
User [email protected]
# Mail Server login password
Password Password
# Set a default account
Account default:163
#5, test MSMTP is configured correctly
MSMTP [email protected]
[Ctrl+d]
#6, installation configuration mutt
Yum Install-y Mutt
Vim/etc/muttrc
#输入如下内容:
Set sendmail= '/usr/bin/msmtp '
Set Use_from=yes
Set Realname= "[Email protected]"
Set [email protected]
Well, let's test it out!
echo "Testmail" | Mutt-s "Test"-a/etc/hosts [email protected]
Here's-a refers to the addition of attachments, if it is multiple attachments, add a few-a file name
I can do that.
Mutt-s "Test"-a/etc/hosts-a/etc/apple [email protected] </tmp/imax.txt
This means to use the contents of the/tmp/imax.txt file as the content of the message.
echo "This is the body" | Mutt-s "Testing" [email protected]-a/etc/hosts-a/etc/apple
All right, that's easy.
Linux under configuration with MSMTP and mutt email