Chapter 47. Filtering Mail
Let’s face it.
procmail is horrid. But for most of us, it’s the only sensible way to handle mail filtering. I used to tolerate
procmail, with its grotesque syntax and its less-than-helpful error messages, because it was the only way I knew to separate out my mail. One day, however, I decided that I’d been told “delivery failed, couldn’t get lock” or similar garbage for the very last time, and I sat down to write a
That’s when it dawned on me that what I really disliked about
procmail was the recipe format. I didn’t want to handle my mail with a collection of colons, zeroes, and single-letter commands that made sendmail.cf look like a Shakespearean sonnet; I wanted to program my mail routing in a nice, high-level language. Something like Perl, for instance.
The result is the astonishingly simple Mail::Audit module. In this article, I’ll examine what can be done with Mail::Audit and how to use it to create mail filters. I’ll also look at the News::Gateway module for turning mailing lists into newsgroups and back again.
What Is It?
Mail::Audit itself isn’t a mail filter—it’s a toolkit that makes it very easy for you to build mail filters. You write a program that describes what should happen to your mail, and this replaces your
procmail command in your .forward or .qmail file.
Mail::Audit provides the functionality for extracting mail headers, bouncing, accepting, rejecting, forwarding, and filtering incoming mail.
A Very Simple ...
Get Computer Science & Perl Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.