為什么是mutt? 為什么mutt需要那么多其他工具才能完成郵件處理?你應該看看王垠的介紹:
http://www.kreny.com/docs/mutt.htm本文只雜亂談一下我的配置經(jīng)驗
先說(shuō)說(shuō)~/.muttrc幾個(gè)基本問(wèn)題,1.建立郵箱,mutt的郵箱有兩種,一種是單文件(所有郵件放到一個(gè)文件里),另一種是mail dir形式,后一種目錄形式比較好,推薦使用。
## folder & spool
set spoolfile = ~/Mail/inbox
set folder = ~/Mail
set tmpdir = ~/.mutt/tmp
set mbox_type = Maildir
set mbox = +inbox
set record = +sent
set postponed = +postponed
mailboxes \
$MAIL \
=inbox \
=junkmail \
=favorites \
=archive
在mailboxes行里,可以定義自己想建立的郵箱,如favorites, archive, junkmail等。
2.編碼問(wèn)題# locale
set charset = UTF-8
set locale = zh_CN.UTF-8
# hook charset
charset-hook !UTF-8 gbk
charset-hook "^us-ascii$" "utf-8"
# send charset
set send_charset="us-ascii:iso-8859-1:utf-8:gbk"
set rfc2047_parameters=yes
charset-hook里設置里非utf-8郵件使用gbk查看
3.增加垃圾箱,雖然不是很完善
#trash
folder-hook . 'macro index d "s$folder/trash\r"'
folder-hook $folder/trash 'bind index d delete-message'
4.排序#sort
set sort = reverse-date
set sort_aux = threads
5.快捷鍵,我是這樣設置的
#key binding getmail
macro index G "!~/.getmail/getmail\n" "Invoke getmail"
macro pager G "!~/.getmail/getmail\n" "Invoke getmail"
#enter mailbox
macro index A "c=archive\r"
macro pager A "c=archive\r"
macro index I "c!\n" "Go to Inbox"
macro pager I "c!\n" "Go to Inbox"
macro index F "c=favorites\r"
macro pager F "c=favorites\r"
macro index J "c=junkmail\r"
macro pager J "c=junkmail\r"
前面一部分是收郵件(getmail),快捷鍵是shift+g,(參見(jiàn)下面getmail配置)
后面一部分是進(jìn)入各個(gè)郵箱的快捷鍵。
6.多賬號發(fā)送問(wèn)題,方法是通過(guò)判斷來(lái)信郵件頭來(lái)選擇,局限是只能在回信時(shí)自動(dòng)選擇。
以下是完整的發(fā)信部分設置
#send hook
send-hook . 'my_hdr from:dream7180@gmail.com'
send-hook . 'set sendmail="/usr/bin/msmtp"'
reply-hook . 'my_hdr reply-to:dream7180@gmail.com'
send-hook '~t .*@163\.com$' 'my_hdr from:dreamawake@163.com'
send-hook '~t .*@163\.com$' 'my_hdr reply-to:dreamawake@163.com'
send-hook '~t .*@163\.com$' 'set sendmail="/usr/bin/msmtp -a 163"'
reply-hook '~t .*@163\.com$' 'my_hdr from:dreamawake@163.com'
reply-hook '~t .*@163\.com$' 'my_hdr reply-to:dreamawake@163.com'
reply-hook '~t .*@163\.com$' 'set sendmail="/usr/bin/msmtp -a 163"'
前面一段是默認的賬號,后面兩段是用163賬號來(lái)發(fā)送(后面提到msmtp的配置)。
msmtp的配置:這里就定義了發(fā)送的賬號,包括gmail和163
getmail的配置對多賬號來(lái)說(shuō),getmail比f(wàn)etchmail配置要復雜,但感覺(jué)收郵件的表現getmail比f(wàn)etchmail要好。
多賬號配置,授先建立~/.getmail目錄,編寫(xiě)~/.getmail/getmailrc.163文件:
[retriever]
type = SimplePOP3Retriever
server = pop.163.com
username =
dreamawake@163.compassword = xxxxxx
[destination]
type = Maildir
path = ~/Mail/inbox/
[options]
verbose = 0
delete =
falsemessage_log = ~/.getmail/getmail.log
諸如此類(lèi),編寫(xiě)~/.getmail/getmailrc.gmail文件
[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
port = 995
username =
dream7180@gmail.compassword = xxxxxx
[destination]
type = Maildir
path = ~/Mail/inbox/
[options]
verbose = 0
delete =
falsemessage_log = ~/.getmail/getmail.log
你可以寫(xiě)更多.....
然后是~/.getmail/getmail文件
#!/bin/bash
#getmail for dream
getmail -v -n -r ~/.getmail/getmailrc.sina -r ~/.getmail/getmailrc.163 -r ~/.getmail/getmailrc.gmail
注意把它設為可運行(+x)。
于是有了上面.muttrc里快捷鍵收郵件那部分配置。
附上我完整的~/.muttrc以供參考
#號開(kāi)頭是注釋
## user
set realname =
"rzli"## folder & spool
set spoolfile = ~/Mail/inbox
set folder = ~/Mail
set tmpdir = ~/.mutt/tmp
set mbox_type = Maildir
set mbox = +inbox
set record = +sent
set postponed = +postponed
mailboxes \
$MAIL \
=inbox \
=junkmail \
=favorites \
=archive
set move = no
# locale
set charset = UTF-8
set locale = zh_CN.UTF-8
# hook charset
charset-hook !UTF-8 gbk
charset-hook
"^us-ascii$" "utf-8"# send charset
set send_charset=
"us-ascii:iso-8859-1:utf-8:gbk"set rfc2047_parameters=yes
#Flag
#
" "(空): 表示這封郵件不是給你的,也就是說(shuō)
To: 和 Cc: Bcc: 都沒(méi)有你的地址,
# 很多轉發(fā)的郵件,未確認的郵件列表郵件,垃圾郵件都有這個(gè)特征。
# +: 表示你是收件人(
To: 是你的地址之一),而且是唯一的收件人。
# T: 表示你是收件人(
To: 包括了你的地址之一),但是你不是唯一的收件人。這是一封群體信件。
# C: 表示你的地址出現在 CC:,但是你不是唯一的被抄送的人。
# F: 表示這封郵件是你發(fā)出去的。
# L: 表示這是一封你已經(jīng)加入的郵件列表寄來(lái)的。
#trash
folder-hook .
'macro index d "s$folder/trash\r"'folder-hook $folder/trash
'bind index d delete-message'#
Set header
ignore headers *
unignore headers from:
to: cc: subject date
set header=no
#
set index
set index_format="%4C %Z %{%y年%b%d} %-15.15L (%?l?%4l&%4c?) %s"
#score
#score
"~N" +4 #新信件
#score
"~D" -5 #有刪除標記
#score
"~O" +1 #上次沒(méi)有讀
#score
"~f huiqin" +2 #來(lái)自 xxxx
#score
"~s xxxx" + 3 #主題上有 xxxx
#sort
set sort = reverse-date
set sort_aux = threads
#confirm
set confirmappend = no
# wrap &
stop @ last mail
set pager_stop = yes
set smart_wrap = yes
set pager_index_lines = 5
# message editor
set editor =
"vim"set fast_reply = yes
set edit_headers = yes
# ext app
to view attachment
set mailcap_path=
"~/.mutt/mailcap"# wait too see output info
while quit
set wait_key=yes
#Alias
set alias_file = ~/.mutt/alias
source ~/.mutt/alias
# Attachment
set attach_format =
"%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "set attach_sep =
"\n"set attach_split = yes
# Color
color hdrdefault black cyan
color quoted red white
color signature brightblack white
color indicator brightwhite magenta
color attachment black green
color
error red white
color message blue white
color search brightwhite magenta
color status brightyellow blue
color tree red white
color normal blue white
color tilde green white
color bold brightyellow white
color markers red white
color index brightwhite red ~N
color index red default ~O
color index brightblack default ~D
mono bold bold
mono underline underline
mono indicator reverse
#
auto_view text/html
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=:-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# include original content when reply
set include = yes
# from
set envelope_from = yes
set encode_from = yes
#send hook
send-hook .
'my_hdr from:dream7180@gmail.com'send-hook .
'set sendmail="/usr/bin/msmtp"'reply-hook .
'my_hdr reply-to:dream7180@gmail.com'send-hook
'~t .*@163\.com$' 'my_hdr from:dreamawake@163.com'send-hook
'~t .*@163\.com$' 'my_hdr reply-to:dreamawake@163.com'send-hook
'~t .*@163\.com$' 'set sendmail="/usr/bin/msmtp -a 163"'reply-hook
'~t .*@163\.com$' 'my_hdr from:dreamawake@163.com'reply-hook
'~t .*@163\.com$' 'my_hdr reply-to:dreamawake@163.com'reply-hook
'~t .*@163\.com$' 'set sendmail="/usr/bin/msmtp -a 163"'#key binding getmail
macro index G
"!~/.getmail/getmail\n" "Invoke getmail"macro pager G
"!~/.getmail/getmail\n" "Invoke getmail"#enter mailbox
macro index A
"c=archive\r"macro pager A
"c=archive\r"macro index I
"c!\n" "Go to Inbox"macro pager I
"c!\n" "Go to Inbox"macro index F
"c=favorites\r"macro pager F
"c=favorites\r"macro index J
"c=junkmail\r"macro pager J
"c=junkmail\r"#
End of muttrc, but it could be more
and more
and more:)