Fetchmail使用簡介

 fetchmail是一個下載郵件的應用程序.他支持POP2,POP3,APOP,IMAP以及ETRN-capable server.他與其他收件程序(Pine,popclient等等)最大的不同是在從郵件服務器獲得郵件後不是直接存入本地信箱,而是將郵件送入本地郵件系統進行再次投遞.
fetchmail近期更新速度很快,最新版本是4.7.0.新老版本的配置文件格式有所不同,下面主要是針對redhat-5.1帶的 fetchmail-4.6.5-1進行介紹,其他版本的fetchmail可能有些差異.最新的fetchmail可以在 sunsite.unc.edu以及其mirror站點找到.

簡單介紹一下fetchmail的使用方法.

fetchmail可以直接從命令行運行,最簡單的用法:
% fetchmail -p POP3 -u isee dns.nuaa.edu.cn
isee是賬戶,dns.nuaa.edu.cn是郵件服務器,使用POP3協議.

如果只是想檢查郵件可以
% fetchmail -p POP3 -u isee -c dns.nuaa.edu.cn
-c(--check)就是隻檢查而不真正取信.

下面是一些常用的fetchmail命令行參數:
-?, --help 顯示幫助
-V, --version 顯示版本號
-c, --check 檢查信箱
-s, --silent 安靜執行,及不輸出任何信息
-v, --verbose 調試輸出,會輸出很詳盡的運行信息
-d, --daemon 以守護進程方式運行
-L, --logfile 指定log文件
--syslog 使用系統log(syslog)
-f, --fetchmailrc 指定運行控制文件
-I, --interface 指定網絡界面
-p, --potocol 指定下載協議
-P, --port 指定端口號
-a, --all 下載所有郵件,包括老郵件
-K, --nokeep 下載後刪除服務器上郵件
-k, --keep 下載後保留服務器上郵件
-F, --flush 刪除服務器上老的郵件
-l, --limit 不下載超過指定大小的郵件
-B, --fetchlimit 指定一次最多下載多少郵件
-r, --folder 指定遠程文件夾名

象其他unix程序一樣,~/.fetchmailrc是fetchmail的缺省配置文件.配製文件中的關鍵字一般都和命令行參數有對應關係.命令行參數的優先級要高於配製文件.

下面是個配製文件的例子:
# Configuration created Fri Nov 6 19:36:16 1998 by fetchmailconf
set syslog
set postmaster "isee"
poll 202.119.64.127 with proto POP3 and options
envelope Delivered-To
user "mere" there with password "xxxxxxx" is [email protected] here
no keep
user "isee" there with password "yyyyyyy" is [email protected] here
no keep

配製文件的語法非常簡單,#號開頭的行作爲註釋,同時忽略所有的there", "here", "and", "with", "has", "wants", "options" 這些單詞在配製文件中只是起增加可讀性的作用.

上面配製文件實際上就是
set syslog
set postmaster "isee"
poll 202.119.64.123 proto POP3
envelope Devlivered-To
user "mere" with password "xxxxxxx" is [email protected] no keep
user "isee" with password "yyyyyyy" is [email protected] no keep

意思就是使用系統log,Postmaster爲isee(主要是投遞發生錯誤時回信的from地址)
Mail server是202.119.64.123
在受到的郵件中加Develivered-To標籤.
郵件賬戶是mere,口令是xxxxxx,轉發給[email protected]
郵件賬戶是isee,口令是yyyyyy,轉發給[email protected]
都不用在mail服務器上保留郵件.

下面列表是配製文件常用的Keyword

Keyword Opt 功能
------------------------------------------------------------------
set logfile 制定log文件
set syslog 使用系統log文件
via 指定DNS機器名來取代poll中的機器明
proto -p 指定協議
port -P 指定端口
timeout -t 指定超時時間
interface -I 指定網絡界面
user -U 指定遠程用戶
is 將本地用戶和遠程用戶聯繫起來
to 同is
pass 口令
folder -r
preconnect 連接開始前執行的外部命令
postconnect 連接結束後執行的外部命令
keep -k
flush -F
fetchall -a
no keep -K
no flush

以上只是對fetchmail的簡單介紹,Fetchmail還有其他很多強大的功能,比如子信箱支持,對qmail虛擬主機後綴的支持等等.

要了解更多的fetchmail信息可以閱讀man fetchmail及相關文檔.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章