1. 程式人生 > >Ubuntu使用mutt收、發、回復郵件(mutt+msmtp+fetchmail+procmail

Ubuntu使用mutt收、發、回復郵件(mutt+msmtp+fetchmail+procmail

mutt

Ubuntu使用mutt收、發、回復郵件(mutt+msmtp+fetchmail+procmail):

說明:
Mutt為基於文本的郵件客戶端,擔當郵件用戶代理角色,msmtp的作用是發郵件(包括回復),fetchmail的作用是將郵件保存到本地郵箱,procmail的作用是進行郵件過濾(根據發件人、主題、關鍵字等對郵件進行排序、分類、整理)。

軟件安裝:
$ sudo apt-get install mutt
$ sudo apt-get install msmtp
$ sudo apt-get install fetchmail
$ sudo apt-get install procmail

Mutt配置:

$ cp –rv /etc/Muttrc ~/.muttrc
$ vi ~/.muttrc
set sendmail="/usr/bin/msmtp"
set use_from=yes
set realname="zhi.yang"
set [email protected]
set envelope_from=yes
:wq

Msmtp配置:
$ vi ~/.msmtprc
account default
host smtp.ming.com
port 587
from [email protected]
user [email protected]

password xxxxx
auth ntlm (auth模式根據郵箱服務器的支持情況而定)
tls off
logfile ~/.msmtp.log
:wq

$ msmtp --host=smtp.ming.com --port 587 --serverinfo(查看郵箱服務器支持的auth模式)

Fetchmail配置:
$ cp –rv /usr/share/doc/fetchmail/examples/fetchmailrc.example ~/.fetchmailrc
$ vi ~/.fetchmailrc
poll smtp.ming.com with protocol pop3
username "[email protected]"

password "xxxxxx"
mda "/usr/bin/procmail -d %T"
no keep
:wq

Procmail配置:
$ vi ~/.procmailrc
VERBOSE=yes
DEFAULT=/var/spool/mail/aa
MAILDIR=$HOME/Mail
LOGFILE=$HOME/.procmail.log
:wq

$ sudo touch /var/spool/mail/aa (此處的aa為隨意寫的,可自行定義)
$ sudo chown zhi.yang /var/spool/mail/aa

使用:
$ fetchmail –v (進行郵件同步)
$ mutt (就能看到收件箱郵件了)
q:退出,r:回復(根據提示操作即可)

發送1人:
$ echo “hello” | mutt -s “title” [email protected]
$ mutt –s “title” [email protected] < ~/aa.txt

發送多人:
$ echo “hello” | mutt -s “title” [email protected] [email protected]

抄送郵件:
$ echo “hello” | mutt -s “title” [email protected] -c [email protected]

密送郵件:
$ echo “hello” | mutt -s “title” [email protected] -b [email protected]

發送附件:
$ echo “hello” | mutt -s “title” [email protected] -a ~/aa.txt

Ubuntu使用mutt收、發、回復郵件(mutt+msmtp+fetchmail+procmail