使用Msmtp mutt shell發郵件
1、編譯一下軟體
軟體:http://sourceforge.net/projects/msmtp/files/msmtp/1.4.13/msmtp-1.4.13.tar.bz2/download
tar jxvf msmtp-1.4.13.tar.bz2
./configure --prefix=/opt/msmtp
make
make install
2、查看設定檔在那兒
[root@server bin]# ./msmtp --version
msmtp version 1.4.13
TLS/SSL library: none
Authentication library: built-in
Supported authentication methods:
plain cram-md5 external login
IDN support: disabled
NLS: enabled, LOCALEDIR is /opt/msmtop/share/locale
System configuration file name: /opt/msmtp/etc/msmtprc -----需要手動建立
User configuration file name: /root/.msmtprc
Copyright (C) 2007 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.
3、配置一下msmtp的設定檔
[root@server ]#mkdir -p /opt/msmtp/{etc,log}
[root@server ]#cd /opt/msmtp/etc
[root@server etc]# vi msmtprc (增加以下內容)
# Set default values for all following accounts.
defaults
logfile /opt/msmtp/log/msmtp.log
# The SMTP server of the provider.
account sohu
host smtp.sohu.com
from your_account@sohu.com
auth login
user your_account
password your_password
# Set a default account
account default : sohu
儲存退出,並對這個檔案加上可執行許可權:chmod +x msmtprc
到這兒時,最好先測試一下
/opt/msmtp/bin/msmtp test@gmail.com
hello,test
ctrl +d
tail -f /opt/msmtp/log/msmtp.log 看看有沒有成功。
然後再進入到上面的郵件中,看看信收到沒有
4、配置mutt
下載並安裝mutt安裝包: mutt-1.5.11.tar.gz
tar -xzvf mutt-1.5.11.tar.gz
./configure --prefix=/opt/mutt &&make &&make install
[root@server bin]# vi /etc/Muttrc (增加以下內容)
set sendmail="/opt/msmtp/bin/msmtp"
set realname="actor"
set use_from=yes
set editor="vi"
5、現在都已經搞定了,開始測試看看
[root@server bin]# echo "測試一下" | mutt -s "messages" test@gmail.com