歡迎您光臨本站 註冊首頁

使用msmtp+mutt+shell發郵件

←手機掃碼閱讀     火星人 @ 2014-03-29 , reply:0

今天在宿舍沒事做,又實在無聊,只好研究些東西,打開電腦發現好久之前下載的msmtp一直沒有研究下,呵呵,因為我已經使用perl搞定我的事情了,不過呢,多一種解決方法也好。開工,解決一下

1、編譯一下軟體
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 <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

3、配置一下msmtp的配置文件
[root@server etc]# more 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 -------這個要為login,好像on不行
user your_account
password your_password
# Set a default account
account default : sohu
到這兒時,最好先測試一下
/opt/msmtp/bin/msmtp yehaozi@gmail.com
hello,test
ctrl+d
tail -f /opt/msmtp/log/msmtp.log 看看有沒有成功。
然後再進入到上面的郵件中,看看信收到沒有

4、配置mutt
我原來在網上一直看到mutt+msmtp發送郵件,我不想裝mutt。(汗啊,後面才發現系統已經裝了)。一直在找怎麼使用msmtp自己來發郵件,郵件可以發,不過功能實在是太少了。那就用已經安裝好了的mutt.

[root@server bin]# tail -5 /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 "管理信息" yehaozi@gmail.com

[火星人 ] 使用msmtp+mutt+shell發郵件已經有651次圍觀

http://coctec.com/docs/linux/show-post-202265.html