Why not adopt me?
NAME
Mail::Audit - Library for creating easy mail filters
SYNOPSIS
use Mail::Audit; # use Mail::Audit qw(...plugins...);
my $mail = Mail::Audit->new;
$mail->pipe("listgate p5p") if ($mail->from =~ /perl5-porters/);
$mail->accept("perl") if ($mail->from =~ /perl/);
$mail->reject("We do not accept spam") if looks_like_spam($mail);
$mail->ignore if $mail->subject =~ /boring/i;
...
DESCRIPTION
procmail is nasty. It has a tortuous and complicated recipe format, and I don't like it. I wanted something flexible whereby I could filter my mail using Perl tests.
Mail::Audit was inspired by Tom Christiansen's audit_mail and deliverlib programs. It allows a piece of email to be logged, examined, accepted into a mailbox, filtered, resent elsewhere, rejected, and so on. It's designed to allow you to easily create filter programs to stick in a .forward file or similar.
CONSTRUCTOR
new(%options)-
The constructor reads a mail message from
STDIN(or, if thedataoption is set, from an array reference) and creates aMail::Auditobject from it, to be manipulated by the following methods.Other options include the
accept,rejectorpipekeys, which specify subroutine references to override the methods with those names.You may also specify
log => $logfileto write a debugging log; you can set the verbosity of the log with theloglevelkey, on a scale of 1 to 4. If you specify a log level without a log file, logging will be written to /tmp/you-audit.log where you is replaced by your user name. If you specifynoexit => 1,Mail::Auditwill not exit after delivering the mail, but continue running your filter.
METHODS
accept($where)-
You can choose to accept the mail into a mailbox by calling the
acceptmethod; with no argument, this accepts to /var/spool/mail/you. The mailbox is opened append-write, then locked LOCK_EX, the mail written and then the mailbox unlocked and closed. If Mail::Audit sees that you have a maildir style system, where /var/spool/mail/you is a directory, it'll deliver in maildir style.If this isn't how you want local delivery to happen, you'll need to override this method.
reject($reason)-
This rejects the email; it will be bounced back to the sender as undeliverable. If a reason is given, this will be included in the bounce.
ignore-
This merely ignores the email, dropping it into the bit bucket for eternity.
pipe($program)-
This opens a pipe to an external program and feeds the mail to it.
tidy-
Tidies up the email as per Mail::Internet
get($header)-
Retrieves the named header from the mail message.
put_header($header, $value)-
Inserts a new header into the mail message with the given value.
replace_header($header, $value)-
Removes the old header, adds a new one.
delete_header($header)-
Guess.
body-
Returns a reference to an array of lines in the body of the email.
header-
Returns the header as a single string.
resend($address)-
Bounces the email in its entirety to another address.
ATTRIBUTES
The following attributes correspond to fields in the mail:
from
to
subject
cc
bcc
LICENSE
The usual. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
BUGS
Fewer than before.
AUTHOR
Simon Cozens <simon@cpan.org>
SEE ALSO
Mail::Internet, Mail::SMTP, Mail::Audit::List, Mail::Audit::PGP, Mail::Audit::MAPS, Mail::Audit::KillDups, Mail::Audit::Razor...