?

Log in

No account? Create an account
Say goodbye to procmail forever. - Adventures in Engineering — LiveJournal
The wanderings of a modern ronin.

Ben Cantrick
  Date: 2006-10-19 06:20
  Subject:   Say goodbye to procmail forever.
Public

Mail::Audit is officially my favorite PERL module ever:

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.

Here's the simplest filter program we can make with Mail::Audit.

use Mail::Audit;
my $incoming = Mail::Audit->new;
$incoming->reject;


If you save this as ~/bin/chuckmail, then you can put the following in a .forward file:

|~/bin/chuckmail

Every mail message you receive will now pass through this program. The mail comes into the program via standard input, and the new() method takes it from there and turns it into a Mail::Audit object.

Next, we bounce it as undeliverable:

$incoming->reject;

We could even get fancy, and supply a reason with the bounce:

$incoming->reject(<<EOF);
The local user was silly enough to leave chuckmail as his
mail filter. Too bad you can't mail him to let him know.
EOF


This reason will be relayed back to the sender as part of the bounce message.


http://www.perl.com/pub/a/2001/07/17/mailfiltering.html?page=1
Post A Comment | | Link






browse
May 2015