In CentOS system, if you want to send mail to foreign domain, you need to configure sendmail + dovecot and other tools. In fact, it doesn’t need to be so troublesome, as long as mutt + msmtp can realize the function of sending e-mail to foreign domains.
This paper is based on centos6 64bit
1. Install and configure msmtp
The code is as follows:
$ wget http://sourceforge.net/projects/msmtp/files/msmtp/1.4.32/msmtp-1.4.32.tar.bz2
$ tar -jxvf msmtp-1.4.32.tar.bz2
$ cd msmtp-1.4.32
$ ./configure –prefix=/usr/local/msmtp
$ cd msmtp-1.4.32
$ make && make install</p>
<p>$ mdkir /usr/local/msmtp/etc
Generate configuration file
The code is as follows:
Directly copy the following content and paste it in the position of the > sign
The code is as follows:
tls on
logfile /usr/local/msmtp/msmtp.log</p>
<p>account acc1
host smtp.163.com
port 25
from [email protected]
auth login
tls off
user [email protected]
password mypasswd</p>
<p>account acc2
host smtp.qq.com
port 465
from [email protected]
auth login
tls_starttls off
tls on
tls_certcheck off
user [email protected]
password mypasswd</p>
<p>account default : acc2
EOF
There are some things to pay attention to in the configuration file:
QQ mailbox does not support TLS, so you need to close TLS when using QQ mailbox_ starttls,
The SSL certificate of Netease free mailbox can not pass the verification, so when using 163 mailbox, only TLS certificate verification can be turned off.
The configuration file does not support Chinese and cannot paste Chinese comments, otherwise an error will be reported.
2. Install and configure mutt
The code is as follows:
$ cat >>/etc/Muttrc<<EOF
Directly copy the following content and paste it in the position of the > sign
The code is as follows:
set use_from=no
set realname=”[email protected]”
set editor=”vim”
EOF
3. Function test
The code is as follows:
No accident, we should be able to receive the mail. If there is no response after 5 seconds, the default account configuration in the msmtprc file is incorrect. You can first execute PS – EF | grep mutt to find out the process number kill, and then modify the relevant configuration in the msmtprc file and try again.