下載msmtp或者mpop(和msmtp同樣小巧的郵件軟件,不在這裏寫過程了。)軟件,當前最新版1.4.30
http://jaist.dl.sourceforge.net/project/msmtp/msmtp/1.4.30/msmtp-1.4.30.tar.bz2
一、編譯軟件
tar jxvf msmtp-1.4.30.tar.bz2
cd msmtp-1.4.30
./configure --prefix=/usr/local/msmtp
make
make install
二、看一下配置文件在哪裏
# /usr/local/msmtp/bin/msmtp --version
msmtp version 1.4.30
Platform: x86_64-unknown-linux-gnu
TLS/SSL library: OpenSSL
Authentication library: built-in
Supported authentication methods:
plain cram-md5 external login
IDN support: enabled
NLS: enabled, LOCALEDIR is /usr/local/msmtp/share/locale
Keyring support: none
System configuration file name: /usr/local/msmtp/etc/msmtprc#默認配置文件的路徑
User configuration file name: /root/.msmtprc
Copyright (C) 2012 Martin Lambers and others.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License
There is NO WARRANTY, to the extent permitted by law.
三、msmtp的配置文件
mkdir -p /usr/local/msmtp/etc
touch /usr/local/msmtp/msmtp.log
vi /usr/local/msmtp/etc/msmtprc
輸入如下內容
defaults
logfile /usr/local/msmtp/msmtp.log
account gmail
tls on
host smtp.gmail.com
port 587
from username@gmail.com
tls_certcheck off
auth login
user username@gmail.com
password password
account default : gmail
四、配置mutt
通常系統已經安裝了,若是沒有安裝的話請使用 yum install mutt 安裝
# tail -5 /etc/Muttrc
#vi /etc/Muttrc.local
set sendmail="/usr/local/msmtp/bin/msmtp"
set realname="測試服務器"
set use_from="yes"
set charset="UTF-8"
set editor="vi"
五、測試一下發送郵件
#echo "測試郵件內容" | mutt -s "測試郵件主題" username@domain.com
tail -f /usr/local/msmtp/msmtp.log 看看有沒有成功,或者進入上面的郵箱看看是否收到郵件。
linux