linux系统下不需启动sendmail类似工具。

#!/bin/sh
# Create by  JIANGLEI.YU
#Define  Configure file
check_result(){
    if [ $1 != 0 ];then
        echo -e "\e[1,44m  <==== Error,Exit install Mutt ====> \e[0m"
        rm -fr  /usr/local/msmtp/etc
        rm -fr  /root/.msmtprc
        rm -fr  /root/.muttrc
        rm -fr  /usr/local/msmtp/etc/msmtprc
        mv      /etc/Muttrc  /etc/Muttrc.$(date +%Y%m%d%H%M%S)
        rm -fr  /tmp/mutt-*
        rm -fr  /usr/local/mutt
        rm -fr  /usr/bin/mutt
        rm -fr  /tmp/msmtp-*
        rm -fr  /usr/local/msmtp
        rm -fr  /usr//bin/msmtp
        exit 1
    fi
}
configure(){
mkdir -p /usr/local/msmtp/etc
check_result $?
cat <<  EOF > /root/.msmtprc   
host smtp.163.com
tls off
auth plain
from [email protected]
user bjjd00001
password Aa123456Aa
EOF
check_result $?
cat << EOF >  /root/.muttrc
set sendmail="/usr/local/msmtp/bin/msmtp"
set use_from=yes
set [email protected]
set envelope_from=yes
EOF
check_result $?
cat  << EOF  >/usr/local/msmtp/etc/msmtprc
defaults
account bjjd00001
host smtp.163.com
from [email protected]
auth login
port 25
tls off
user  [email protected]
password Aa123456Aa
account default: bjjd00001
logfile /usr/local/msmtp/log/msmtp.log
EOF
check_result $?
echo 'setsendmail="/usr/local/msmtp/bin/msmtp"' >>/etc/Muttrc
check_result $?
echo "set use_from=yes" >>/etc/Muttrc
check_result $?
echo 'set realname="[email protected]"'>>/etc/Muttrc
check_result $?
echo 'set editor="vim"' >>/etc/Muttrc
check_result $?
}
install_mutt_msmtp(){
#Download url
#
yum  install  ncurses-devel wget -y 
wget  ftp://ftp.mutt.org/pub/mutt/mutt-1.5.24.tar.gz  -P  /tmp
check_result $?
cd /tmp 
tar  xf   mutt-1.5.24.tar.gz
check_result $?
cd mutt-1.5.24
./configure --prefix=/usr/local/mutt
check_result $?
make
check_result $?
make  install
check_result $?
ln -s /usr/local/mutt/bin/mutt  /usr/bin
check_result $?
#Download url
#https://sourceforge.net/projects/msmtp/
wget https://sourceforge.net/projects/msmtp/files/msmtp/1.6.3/msmtp-1.6.3.tar.xz  -P  /tmp
check_result $?
cd /tmp
tar   xf  msmtp-1.6.3.tar.xz
check_result $?
cd  msmtp-1.6.3
./configure --prefix=/usr/local/msmtp
check_result $?
make 
check_result $?
make  install
check_result $?
ln -s /usr/local/msmtp/bin/msmtp /usr/bin
check_result $?
}
configure
install_mutt_msmtp