6.6.1. maildrop 配置

maildrop(1) 配置在 maildropfilter documentation 中有说明。这里有一个关于 “$HOME/.mailfilter 文件的配置例子。

  1. # Local configuration
  2. MAILROOT="$HOME/Mail"
  3. # set this to /etc/mailname contents
  4. MAILHOST="example.dom"
  5. logfile $HOME/.maildroplog
  6. # rules are made to override the earlier value by the later one.
  7. # mailing list mails ?
  8. if ( /^Precedence:.*list/:h || /^Precedence:.*bulk/:h )
  9. {
  10. # rules for mailing list mails
  11. # default mailbox for mails from mailing list
  12. MAILBOX="Inbox-list"
  13. # default mailbox for mails from debian.org
  14. if ( /^(Sender|Resent-From|Resent-Sender): .*debian.org/:h )
  15. {
  16. MAILBOX="service.debian.org"
  17. }
  18. # default mailbox for mails from bugs.debian.org (BTS)
  19. if ( /^(Sender|Resent-From|Resent-sender): .*@bugs.debian.org/:h )
  20. {
  21. MAILBOX="bugs.debian.org"
  22. }
  23. # mailbox for each properly maintained mailing list with "List-Id: foo" or "List-Id: ...<foo.bar>"
  24. if ( /^List-Id: ([^<]*<)?([^<>]*)>?/:h )
  25. {
  26. MAILBOX="$MATCH2"
  27. }
  28. }
  29. else
  30. {
  31. # rules for non-mailing list mails
  32. # default incoming box
  33. MAILBOX="Inbox-unusual"
  34. # local mails
  35. if ( /Envelope-to: .*@$MAILHOST/:h )
  36. {
  37. MAILBOX="Inbox-local"
  38. }
  39. # html mails (99% spams)
  40. if ( /DOCTYPE html/:b ||\
  41. /^Content-Type: text\/html/ )
  42. {
  43. MAILBOX="Inbox-html"
  44. }
  45. # blacklist rule for spams
  46. if ( /^X-Advertisement/:h ||\
  47. /^Subject:.*BUSINESS PROPOSAL/:h ||\
  48. /^Subject:.*URGENT.*ASISSTANCE/:h ||\
  49. /^Subject: *I NEED YOUR ASSISTANCE/:h )
  50. {
  51. MAILBOX="Inbox-trash"
  52. }
  53. # whitelist rule for normal mails
  54. if ( /^From: .*@debian.org/:h ||\
  55. /^(Sender|Resent-From|Resent-Sender): .*debian.org/:h ||\
  56. /^Subject: .*(debian|bug|PATCH)/:h )
  57. {
  58. MAILBOX="Inbox"
  59. }
  60. # whiltelist rule for BTS related mails
  61. if ( /^Subject: .*Bug#.*/:h ||\
  62. /^(To|Cc): .*@bugs.debian.org/:h )
  63. {
  64. MAILBOX="bugs.debian.org"
  65. }
  66. # whitelist rule for getmails cron mails
  67. if ( /^Subject: Cron .*getmails/:h )
  68. {
  69. MAILBOX="Inbox-getmails"
  70. }
  71. }
  72. # check existance of $MAILBOX
  73. `test -d $MAILROOT/$MAILBOX`
  74. if ( $RETURNCODE == 1 )
  75. {
  76. # create maildir mailbox for $MAILBOX
  77. `maildirmake $MAILROOT/$MAILBOX`
  78. }
  79. # deliver to maildir $MAILBOX
  80. to "$MAILROOT/$MAILBOX/"
  81. exit
[警告]警告

不像 procmailmaildrop 不会自动创建不存在的 maildir 目录。你必须提前使用 maildirmake(1) 手动创建它们,正如 “$HOME/.mailfilter“ 例子里的那样。