Ben Cantrick (mackys) wrote,
Ben Cantrick

Say goodbye to procmail forever.

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;

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


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:


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

The local user was silly enough to leave chuckmail as his
mail filter. Too bad you can't mail him to let him know.

This reason will be relayed back to the sender as part of the bounce message.
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.