getmail 或许是更好的选择

一直以来,都是用 fetchmail 将邮件收取到本地,但当我浏览了 getmail 的主页后,发现 getmail 不仅功能强大,而且配置起来比 fetchmail 简单许多。

下面是我用 getmail 收取 gmail 的配置($HOME/.getmail/gmail.rc): 

[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
port = 995
username = username@gmail.com
password = secret

[destination]
type = MDA_external
path = /usr/bin/procmail
arguments = ("-f", "%(sender)")

[options]
read_all = false
message_log = ~/.getmail/getmail.log

你可以将每个邮箱的配置保存成一个单独的文件,比如说 126.rc、yahoo.rc,然后通过脚本调用:

#!/bin/bash
rcfiles=""
cd $HOME/.getmail
for file in *.rc;do
  rcfiles="$rcfiles –rcfile $file"
done
exec /usr/bin/getmail $rcfiles $@

最后将脚本放入 cron,定期收取邮件,比如说每隔15分钟收取一次。

*/15 * * * * /home/centeur/bin/getmail.sh -q

Tags: ,

This entry was posted on Friday, June 20th, 2008 at 5:37 pm and is filed under linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Posts you may enjoy

Leave a Reply

Please copy the string 6FdV7a to the field below: