I’m what you might call a heavy procmail user. My procmailrc spans about
700 lines in six files, plus three or four additional programs to
reformat and handle messages along the way.
I’m currently in the process of moving to Dreamhost, though, and there’s one
mail problem there that I had to work around: they don’t support
plus addressing (where user+ext@domain is
delivered to user@domain), and I use that feature pretty heavily.
They do support wildcards, though, so the obvious solution was
to tell them to accept everything and then handle deliverable vs
undeliverable addresses in procmail.
To do that, I have to extract the address that appeared in the RCPT TO from
a Received: header, and that seemed ugly. For a while I’ve considered
moving my mail filtering over to Mail::Audit, and this seemed like a good opportunity. And was it ever! I wish I’d
done this years ago.
Easy things are pretty easy in both. For instance, here’s how I
make sure all mail coming from LiveJournal gets put in a particular
mailbox in procmail:
:0 * ^From:.*@livejournal\.com $MAILDIR/IN.Livejournal/
and in Mail::Audit:
$m->accept("$MAILDIR/IN.Livejournal/") if $m->from =~ /@livejournal\.com/i;
But where it really starts to get easier are the things that
aren’t easy in procmail, like adding a Lines: header if one
is missing, done like so in procmail:
:0 * ! ^Lines: { :0 B * 1^1 ^.*$ { } LINES = $=:0 fhw | formail -a "Lines: $LINES" }
and in Mail::Audit:
my $lines = do { my @tmp = split("\n", $m->{obj}->as_string) }; $m->replace_header("Lines", $lines);
Integrating SpamAssassin is straightforward, too — it began as
a Mail::Audit plugin, and the spamassassin executable is just
a wrapper around that plugin.
Happy mendel!
(It was odd going through years of accumulated procmailrc, though, in
which I found neat things like killfilters for “hahaha@sexyfun.net”.
Ah, those were the days.)
3 responses to “Mail::Audit”
But I already know all the obscure procmail syntax!
I don’t want to learn a whole other language for mail processing. PROCMAIL 4 LYFE!
It’s funny, because I said that for a long time, but then I realized: Yes, for simple things, procmail is easier to pick up than perl, but HEY WAIT I ALREADY KNOW PERL!!1! and then it all made sense. The clue that I should move was the number of little perl scripts that procmail called.
I decided not to use procmail ages ago. I don’t think I got heavily into Mail::Audit, but my filter makes heavy use of Mail::Header (I think Mail::Audit is also by Graham Barr).
Let me know if you want a copy.
Peter S