set maximum-size 24M
#set delete-oversized
set default-user "nicholas"
#set allow-multiple
set purge-after none

# Use dotlock locking, since FreeBSD doesn't like anything else on NFS.
set lock-types dotlock

# The following strings are replaced in pipe commands and maildir/mbox
# paths:
#       %a: account name
#       %s: account-specific string
#       %h: user's home directory
#       %n: user's uid
#       %t: action name if performing action
#       %u: name of user
#       %H: current hour (00-23)
#       %M: current minute (00-59)
#       %S: current second (00-59)
#       %d: current day of the month (00-31)
#       %m: current month (01-12)
#       %y: current year
#       %W: current day of the week (0-6, Sunday is 0)
#       %Y: current day of the year (000-365)
#       %Q: current quarter (1-4)

# Macro holding the path where the maildirs are.
$path = "%h/mail"

# Create an action called "drop" that will just drop any mail.
action "drop" drop

# An action to keep mail (leave it on the server).
action "keep" keep

# Various test actions so I get to see when fdm blows up.
action "cat" rewrite "cat"
action "invalid" maildir "${path}/invalid"
action "mbox" mbox "${path}/mbox" compress

# My main inbox and junk mail directories.
action "inbox" maildir "${path}/inbox"
action "junk" maildir "${path}/junk"

# Full disclosire mailing list and preprocess action to strip lame subject.
action "full-disclosure" maildir "${path}/full-disclosure"
action "strip-full-disclosure"
	rewrite "sed 's/^\\(Subject:.*\\)\\[Full-disclosure\\] /\\1/'"

# Ditto for the marxism mailing list.
action "marxism" maildir "${path}/marxism"
action "strip-marxism" rewrite "sed 's/^\\(Subject:.*\\)\\[Marxism\\] /\\1/'"

# Other mailing lists.
action "bugtraq" maildir "${path}/bugtraq"
action "forensics" maildir "${path}/forensics"
action "freebsd-hackers" maildir "${path}/freebsd-hackers"
action "linux-kernel" maildir "${path}/linux-kernel"
action "netbsd-source-changes" maildir "${path}/netbsd-source-changes"
action "netbsd-tech-kern" maildir "${path}/netbsd-tech-kern"
action "netbsd-tech-misc" maildir "${path}/netbsd-tech-misc"
action "openbsd-bugs" maildir "${path}/openbsd-bugs"
action "openbsd-misc" maildir "${path}/openbsd-misc"
action "openbsd-ports" maildir "${path}/openbsd-ports"
action "openbsd-source-changes" maildir "${path}/openbsd-source-changes"
action "openbsd-tech" maildir "${path}/openbsd-tech"
action "openbsd-www" maildir "${path}/openbsd-www"
action "pf" maildir "${path}/pf"
action "secureshell" maildir "${path}/secureshell"

# Account definitions.
account "gmx" pop3 server "pop.server1"
	user "xxx" pass "yyy"
account "ntlworld" pop3	server "pop.server2"
	user "xxx" pass "yyy"
account "gmail1" pop3s server "pop.googlemail.com" port 995
	user "xxx" pass "yyy"
account "gmail2" pop3s server "pop.googlemail.com" port 995
	user "xxx" pass "yyy"
account "gmail3" pop3s server "pop.googlemail.com" port 995
	user "xxx" pass "yyy"
account "eutonian" imap server "pop.server3"
	user "xxx" pass "yyy"

# The stdin account is disabled: it will be ignored unless explicitly requested
# using the -a switch on the command line.
account "stdin" disabled stdin

# Catch local mail early.
match "^From:.*root@[a-z]*.nicm.ath.cx" in headers account "stdin"
	action "inbox"

# ------------------------------------------------------------------------------
# I like to only keep mail in my maildirs for 30 days, after which it is
# archived to mboxes which are easier to grep, and which I rm -Rf periodically.
# This section defines the rules fdm needs to do the archiving: with these, I
# can have cron run "fdm -vaarchive f" every 10 days or so, and everything is
# gravy.
# ------------------------------------------------------------------------------
account "archive" disabled maildirs {
	"${path}/bugtraq"
	"${path}/forensics"
	"${path}/freebsd-hackers"
	"${path}/full-disclosure"
	"${path}/linux-kernel"
	"${path}/marxism"
	"${path}/netbsd-source-changes"
	"${path}/netbsd-tech-kern"
	"${path}/netbsd-tech-misc"
	"${path}/openbsd-bugs"
	"${path}/openbsd-misc"
	"${path}/openbsd-ports"
	"${path}/openbsd-source-changes"
	"${path}/openbsd-tech"
	"${path}/secureshell"
	"${path}/news-agvp"
	"${path}/news-clax"
	"${path}/news-clc"
	"${path}/news-colds"
	"${path}/news-csc"
	"${path}/news-cubom"
	"${path}/news-cup"
}
action "archive" mbox "${path}/%s-archives/%s-%yq%Q" compress

# Archive mail older than 30 days.
match age > 30 days account "archive" action "archive"

# Don't let any other mail get to the normal rules.
match all account "archive" action "keep"
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
# Spam from work account.
# ------------------------------------------------------------------------------
account "work" disabled imap server "pop.server4" port 143
	user "xxx" pass "yyy" folder "Junk" keep
action "spam-work" maildir "${path}/spam-work"

match all account "work" action "spam-work"
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
# Newsgroups. These are disabled so I can run them using a "fdm -anews f" from
# a seperate cronjob less often than normal mail accounts. I keep all my
# newsgroups in the same cache, but it is possible to use a seperate cache for
# each by having a seperate account for each group (using a similar prefix,
# such as "news-" for the account name, so you can do "fdm -anews-\* f" is
# useful for this case, as is the %s token in the cache path, which is
# replaced with the group name if only one group is specified).
# ------------------------------------------------------------------------------
action "news-alt.games.vga-planets" maildir "${path}/news-agvp"
action "news-comp.lang.asm.x86" maildir "${path}/news-clax"
action "news-comp.lang.c" maildir "${path}/news-clc"
action "news-comp.os.linux.development.system" maildir "${path}/news-colds"
action "news-comp.std.c" maildir "${path}/news-csc"
action "news-comp.unix.bsd.openbsd.misc" maildir "${path}/news-cubom"
action "news-comp.unix.programmer" maildir "${path}/news-cup"

account "news" disabled nntp
	server "news.ntlworld.com"
	groups {
		"alt.games.vga-planets"
		"comp.lang.asm.x86"
		"comp.lang.c"
		"comp.os.linux.development.system"
		"comp.std.c"
		"comp.unix.bsd.openbsd.misc"
		"comp.unix.programmer"
	}
	cache "%h/.fdm.cache"

match all account "news" {
	match "\\<HTML\\>" in body action "junk"
	match string "%s" to "alt.games.vga-planets" action "news-%s"
	match string "%s" to "comp.lang.asm.x86" action "news-%s"
	match string "%s" to "comp.lang.c" action "news-%s"
	match string "%s" to "comp.os.linux.development.system" action "news-%s"
	match string "%s" to "comp.std.c" action "news-%s"
	match string "%s" to "comp.unix.bsd.openbsd.misc" action "news-%s"
	match string "%s" to "comp.unix.programmer" action "news-%s"
	match all action "drop"
}
# ------------------------------------------------------------------------------

# Copy invalid dates to a special action so I can inspect them.
match age invalid action "invalid" continue

# Test rewriting through cat.
match all action "cat" continue

# Test mbox delivery (also a handy backup, sometimes).
match size > 1K and size < 4K action "mbox" continue

# Drop HTML mail to gmail accounts.
match "\\<HTML\\>" in body account "gmail*" action "junk"

# Junk (eejits).
match ".*YAHOO.*BOOTER.*" in body action "junk"
match "^From:.*clock@twibright.com" in headers action "junk"
match "^From:.*dfeustel@mindspring.com" in headers action "junk"
match "^From:.*eric-list-openbsd-misc@catastrophe.net" in headers action "junk"
match "^From:.*juhasaarinen@gmail.com" in headers action "junk"
match "^From:.*peter_philipp@freenet.de" in headers
	or "^From:.*philipp.peter@freenet.de" in headers action "junk"
match "^From:.*suck@my-balls.com" in headers action "junk"
match "^From:.*chefren@pi.net" in headers action "junk"

# Junk (spam).
match "^From:.*@*.chase.com" in headers action "junk"
match "^From:.*@*.chaseonline.com" in headers action "junk"
match "^From:.*@citi-bank.com" in headers action "junk"
match "^From:.*@emaillabs.com" in headers action "junk"
match "^From:.*baypos@gmail.com" in headers action "junk"
match "^From:.*E-Greeting" in headers action "junk"

# Junk (ISP garbage).
match "^From:.*@newsletter.ntlworld.com" in headers action "junk"
match "^From:.*mailings@(gmx.net|gmx-gmbh.de)" in headers account "gmx"
	action "junk"

# openbsd
# All my openbsd actions are named openbsd-<something>, where <something> is
# the same as the sender the mail comes from, so I can shorthand this into
# these four rules by using a subexpression and an action with %1 (which
# matches the first subexpression in the most recently evaluated regexp). I do
# need a special-case rule for gnats, which should go into openbsd-bugs as well
# as mails to bugs@, and announce, which I want in my inbox.
match "^Sender:[ \t]*owner-([a-z-]*)@openbsd\\.org" in headers {
	match string "%1" to "announce" action "inbox"
	match string "%1" to "gnats" action "openbsd-bugs"
	match all action "openbsd-%1"
}

# netbsd
match "^Sender:[ \t]*([a-z-]*)-owner@NetBSD\\.org" in headers action "netbsd-%1"

# pf
match "^Sender:[ \t]*owner-pf@benzedrine.cx" in headers action "pf"

# *@securityfocus.com (secureshell/bugtraq/forensics)
match "^List-Post:.*secureshell@securityfocus\\.com" in headers
	action "secureshell"
match "^List-Id:.*<([a-z-]*)\\.list-id\\.securityfocus\\.com>" in headers
	action "%1"

# full-disclosure
match "^List-Id:.*<full-disclosure\\.lists\\.grok\\.org\\.uk>" in headers
	actions { "strip-full-disclosure" "full-disclosure" }

# freebsd
match "^Sender:.*owner-freebsd-([a-z-]*)@freebsd\\.org" in headers {
	match string "%1" to "announce" action "inbox"
	match all action "freebsd-%1"
}

# marxism
match "^X-BeenThere:.*marxism@lists.econ.utah.edu" in headers
	actions { "strip-marxism" "marxism" }

# linux-kernel
match "^X-Mailing-List:.*linux-kernel@vger.kernel.org" in headers
	or "^(To:|Cc:):.*@vger.kernel.org" in headers
	action "linux-kernel"

# default
match all action "inbox"
