Contents[hide] |
Mutt是一個(gè)基于ncurse的Email客戶端。
本文使用:
通過(guò)下列命令進(jìn)行安裝。
# pacman -S mutt offlineimap getmail procmail msmtp
修改配置文件
set mbox_type=Maildirset folder=$HOME/.mailset spoolfile=~/.mail/set header_cache=~/.mail/.hcache
spoolfile里要有cur,new和tmp三個(gè)文件夾。
$ mkdir -p ~/mail/{cur,new,tmp}
這是一個(gè)最精簡(jiǎn)的配置文件,能讓你訪問(wèn)你的Maildir,并在收件箱(INBOX)中檢查新Email。
spoolfile告訴Mutt從本地哪個(gè)目錄來(lái)得到新Email。這里我們改到用戶目錄下。你還可以添加更多的Spoolfiles,例如郵件列表所在的目錄。
運(yùn)行下列命令,如果有+IMAP則說(shuō)明Mutt已經(jīng)編譯進(jìn)了內(nèi)置IMAP支持。Arch源里的Mutt默認(rèn)開啟。
$ mutt -v
首先要啟用Community軟件庫(kù),并通過(guò)一個(gè)簡(jiǎn)單的命令 pacman -S offlineimap
來(lái)安裝 OfflineIMAP。 現(xiàn)在你要按自己的需要來(lái)設(shè)置好它。創(chuàng)建一個(gè)文件~/.offlineimaprc
并用你i喜愛的編輯器來(lái)編輯它。下面是一個(gè)配置文件的例子??砂醋约旱男枰獊?lái)編輯它。
[general]accounts = myaccount # change to whatever you wantui = Curses.Blinkenlights # Gives you a nice blinky output on the console so you know what's happening.# ui = Noninteractive.Quiet # If uncommented, this would show nothing at all. Great for cronjobs or background-processes[Account myaccount]localrepository = mylocal # Profile-Name for the local Mails for a given Accountremoterepository = myremote # Profile-Name for the remote Mails for a given Accountautorefresh = 5 # fetches your mails every 5 Minutes[Repository mylocal]type = Maildir # Way of storing Mails locally. Only Maildir is currently supportedlocalfolders = ~/Mail # Place where the synced Mails should be[Repository myremote]type = IMAP # Type of remote Mailbox. Only IMAP is supported right now.remotehost = imap.myhost.com # Where to connectssl = yes # Whether to use SSL or not# remoteport = 993 # Would specify a port if uncommented. That way, it just tries to use a default-portremoteuser = myremoteusername # Login-Nameremotepass = myremotepassword # Login-Password. -- ACHTUNG! Of course, this is not too safe. Make sure that the file is readable only by you. Even better: use some of the suggestions in the OfflineIMAP-Manual to make it safer.
這是讓你能運(yùn)行起來(lái)的最小設(shè)置了。更多高級(jí)的特性,請(qǐng)參看OfflineIMAP的主頁(yè),再回頭看一看annotated offlineimaprc.
現(xiàn)在就快準(zhǔn)備好運(yùn)行OfflineIMAP了。創(chuàng)建一個(gè)已經(jīng)在offlineimaprc中定義好的目錄,就f像這樣: mkdir ~/Mail
。然后運(yùn)行offlineimap
。你的Email就會(huì)同步到本地電腦上了。如果出了什么錯(cuò),就仔細(xì)查看一下錯(cuò)誤消息。通常OfflineIMAP對(duì)于問(wèn)題的提示在文字上是比較詳盡的。
編輯~/.getmail/getmailrc
下面是一個(gè)使用Gmail的例子。
[retriever]type = SimplePOP3SSLRetrieverserver = pop.gmail.comusername = username@gmail.comport = 995password = password[destination]type = Maildirpath = ~/mail/
你可以參考更多配置文件/usr/share/doc/getmail-4.20.0/getmailrc-example
現(xiàn)在可以運(yùn)行g(shù)etmail了。如果它正常工作,可以為getmail創(chuàng)建一個(gè)計(jì)劃任務(wù)Cron,讓它每隔一段時(shí)間就運(yùn)行一次。 此設(shè)置可以每隔三十分鐘,運(yùn)行一次getmail
。
$ crontab -e$ */30 * * * * /usr/bin/getmail
Procmail是一個(gè)強(qiáng)大的郵件分撿工具。
修改getmail設(shè)置
[destination]type = MDA_externalpath = /usr/bin/procmail
配置procmail,下面將對(duì)來(lái)自happy-kangaroos 郵件列表,以及來(lái)自親朋好友的所有Email作一個(gè)排序,每個(gè)人都有各自的Maildir。
MAILDIR=$HOME/mailDEFAULT=$MAILDIR/inbox/LOGFILE=$MAILDIR/log:0:* ^To: happy-kangaroos@nicehost.comhappy-kangaroos/:0:* ^From: loveydovey@iheartyou.netlovey-dovey/
保存.procmailrc后,運(yùn)行g(shù)etmail,看看它是否在適當(dāng)?shù)哪夸浿袑?duì)你的郵件成功排序了。
無(wú)論你是用 POP 還是 IMAP 來(lái)接收Email,都可能要用SMTP來(lái)發(fā)送郵件。
Msmtp是一個(gè)很簡(jiǎn)單易用的SMTP客戶端。它在[extra]
軟件庫(kù)中。
pacman -S msmtp
用編輯器打開 ~/.msmtprc
。下面是一個(gè)使用Gmail帳戶的 .msmtprc
配置例子:
account defaulthost smtp.gmail.comport 587protocol smtpauth onfrom username@gmail.comuser username@gmail.compassword mypasswordtls ontls_starttls on
僅用戶本人才能有此文件的讀寫權(quán)限:
chmod 600 ~/.msmtprc
用 1.4.11 版的 msmtp 時(shí),必然要涉及到設(shè)定 TLS 。 msmtp, TLS, and ArchLinux 對(duì)于如何配置 msmtp 的認(rèn)證作出了指導(dǎo)。
現(xiàn)在 mutt 一定已經(jīng)為使用msmtp作好了配置工作。建一個(gè)目錄: ~/.mutt/
,并打開了 ~/.mutt/muttrc
。下面的配置文件會(huì)讓你開始查看和發(fā)送Email。
set realname='Disgruntled Kangaroo'set sendmail="/usr/bin/msmtp"set edit_headers=yesset folder=~/mailset mbox=+mboxset spoolfile=+inboxset record=+sentset postponed=+draftsset mbox_type=Maildirmailboxes +inbox +lovey-dovey +happy-kangaroos
現(xiàn)在,啟動(dòng) mutt。你會(huì)在 ~/mail/inbox
看到所有的郵件。按下 m
鍵來(lái)撰寫郵件, (它會(huì)使用 EDITOR
環(huán)境變量中定義好的編輯器。如果這個(gè)變量還沒有被設(shè)定,那么可鍵入 export EDITOR=/path/to/yourfavorite/editor
。想要測(cè)試一下,可以給自己發(fā)一封郵件。寫好信后,在你的編輯器中保存它。再返回到Mutt中,它會(huì)顯示出這封郵件的消息。按 y
來(lái)發(fā)送它。如果都正常,那么就恭喜了!你能用Mutt了!不過(guò)呢,要實(shí)現(xiàn)Mutt真正強(qiáng)大的能力,還要作一些進(jìn)一步的定制才行啊。
一份關(guān)于使用與定制Mutt的指南:
xterminus 是mutt社區(qū)中相當(dāng)活躍的人。可以從 Code and Configs Page 找到他的個(gè)人配置文件。如果你有什么特別的問(wèn)題,請(qǐng)隨意在 the irc channel 上提問(wèn)。
在你的家目錄($HOME)中創(chuàng)建一個(gè) .signature
文件。你的簽名會(huì)在附在郵件的后面。
你可以在$HOME創(chuàng)建一個(gè) ./mutt
目錄,如果沒有的話。 再創(chuàng)建一個(gè)名為 macros 的文件。 加入下面的內(nèi)容:
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'
然后安裝 urlview :
pacman -S urlview
在$HOME創(chuàng)建一個(gè) .urlview 文件,并加入下面的內(nèi)容:
REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]COMMAND firefox %s
當(dāng)用Mutt閱讀郵件時(shí),點(diǎn)擊 ctrl+b ,將會(huì)列出郵件中所有的超級(jí)鏈接 urls 。用箭頭按鍵上下翻動(dòng)它們,然后在要訪問(wèn)的鏈接上點(diǎn)擊 enter 。Firefox 將啟動(dòng),并訪問(wèn)那個(gè)站點(diǎn)了。
要將文本的寬度限制在 72 個(gè)字符, 可編輯你的 .vimrc 文件,并加入:
au BufRead /tmp/mutt-* set tw=72
這樣,Vim 只有在你使用 Mutt 的時(shí)候,都會(huì)有上面的行為了。
要設(shè)置另外一個(gè)臨時(shí)文件目錄,如 ~/.tmp,可在你的 .muttrc 文件中加上一行,如下所示:
set tmpdir="~/.tmp"
要重新格式化一個(gè)調(diào)整過(guò)的文本,可參看 Vim 的幫助文件:
:h 10.7
便于命令行使用,或者和cron組合完成自動(dòng)發(fā)送郵件,或者自動(dòng)發(fā)送文件進(jìn)行備份。
mutt -s "this is a great subject" myfriend@gmail.com -a attach.tar.gz < /path/to/content
解決中文附件名為亂碼的問(wèn)題
set rfc2047_parameters=yes
聯(lián)系客服