| Mail-Audit-List documentation | Contained in the Mail-Audit-List distribution. |
Mail::Audit::List - Mail::Audit plugin for automatic list delivery
use Mail::Audit qw(List);
my $mail = Mail::Audit->new;
...
$mail->list_accept || $mail->accept;
This is a Mail::Audit plugin which provides a method for automatically
delivering mailing lists to a suitable mainbox. It requires the CPAN
Mail::ListDetector module.
list_accept($delivery_dir, \%arg)Attempts to deliver the message as a mailing list. It will place each
message in $deliver_dir/$list_name. The default value of $deliver_dir
is $ENV{HOME} . "/mail".
For instance, mail to perl5-porters@perl.org will end up by default in
/home/you/mail/perl5-porters.
Calls accept and returns the filename delivered to if
Mail::ListDetector can identify this mail as coming from a mailing
list, or 0 otherwise.
Valid named arguments are:
munge_name - a coderef called to munge the name given by Mail::ListDetector
Note that if you want to use the defailt delivery location, but also to pass args, you must call the method like this:
$audit->list_accept(undef, { ... });
The recipe given above should be able to replace a great number of special-casing recipes.
Michael Stevens <michael@etla.org>
| Mail-Audit-List documentation | Contained in the Mail-Audit-List distribution. |
package Mail::Audit::List; use Mail::Audit; use vars q(@VERSION); $VERSION = '1.852'; 1; package Mail::Audit; use strict; use Mail::ListDetector; my $DEFAULT_DIR = $ENV{HOME} . "/mail"; sub list_accept { my ($self, $dir, $arg) = @_; $dir ||= $DEFAULT_DIR; $arg ||= {}; my $list = Mail::ListDetector->new($self); if (!(defined $list)) { return 0; } else { my $name = $list->listname; $name =~ tr/A-Za-z0-9_-//dc; $name = $arg->{munge_name}->($name) if $arg->{munge_name}; return 0 unless $name; my $deliver_filename = join '/', $dir, $name; $self->accept($deliver_filename); return $deliver_filename; } } 1; __END__