6.5.1. getmail 配置

getmail(1) 的配置在getmail documentation里描述.这里是我作为用户搭建访问多个 POP3帐号.

按如下所示的创建 “/usr/local/bin/getmails“。

  1. #!/bin/sh
  2. set -e
  3. if [ -f $HOME/.getmail/running ]; then
  4. echo "getmail is already running ... (if not, remove $HOME/.getmail/running)" >&2
  5. pgrep -l "getmai[l]"
  6. exit 1
  7. else
  8. echo "getmail has not been running ... " >&2
  9. fi
  10. if [ -f $HOME/.getmail/stop ]; then
  11. echo "do not run getmail ... (if not, remove $HOME/.getmail/stop)" >&2
  12. exit
  13. fi
  14. if [ "x$1" = "x-l" ]; then
  15. exit
  16. fi
  17. rcfiles="/usr/bin/getmail"
  18. for file in $HOME/.getmail/config/* ; do
  19. rcfiles="$rcfiles --rcfile $file"
  20. done
  21. date -u > $HOME/.getmail/running
  22. eval "$rcfiles $@"
  23. rm $HOME/.getmail/running

按如下所示的配置它。

  1. $ sudo chmod 755 /usr/local/bin/getmails
  2. $ mkdir -m 0700 $HOME/.getmail
  3. $ mkdir -m 0700 $HOME/.getmail/config
  4. $ mkdir -m 0700 $HOME/.getmail/log

按如下所示的为每个 POP3 账户创建 “$HOME/.getmail/config/pop3_name“ 配置文件。

  1. [retriever]
  2. type = SimplePOP3SSLRetriever
  3. server = pop.example.com
  4. username = pop3_name@example.com
  5. password = <your-password>
  6. [destination]
  7. type = MDA_external
  8. path = /usr/bin/maildrop
  9. unixfrom = True
  10. [options]
  11. verbose = 0
  12. delete = True
  13. delivered_to = False
  14. message_log = ~/.getmail/log/pop3_name.log

按如下所示的配置它。

  1. $ chmod 0600 $HOME/.getmail/config/*

计划使用 cron(8) 每 15 分钟运行一次 “/usr/local/bin/getmails“,通过执行 “sudo crontab -e -u <user_name>“ 并把如下所示的命令添加到用户的 cron 条目中。

  1. 5,20,35,50 * * * * /usr/local/bin/getmails --quiet
[提示]提示

POP3 访问的问题可能并不来自于 getmail。一些主流的免费 POP3 服务可能违反了 POP3 协议并且它们的垃圾邮件过滤机制可能不是非常完美。例如,它们可能在刚刚接收到 RETR 命令并且没有接收到 DELE 命令就可能删除了邮件并且可能隔离邮件到垃圾邮件信箱。你应该尽可能的减少损害,通过配置它们使之成为可访问的归档文件并且不要删除它们。参见 “Some mail was not downloaded”