| Email-LocalDelivery documentation | Contained in the Email-LocalDelivery distribution. |
Email::LocalDelivery - Deliver a piece of email - simply
use Email::LocalDelivery; my @delivered_to = Email::LocalDelivery->deliver($mail, @boxes);
This module delivers an email to a list of mailboxes.
This takes an email, as a plain string, and a list of mailboxes to
deliver that mail to. It returns the list of boxes actually written to.
If no boxes are given, it assumes the standard Unix mailbox. (Either
$ENV{MAIL}, /var/spool/mail/you, /var/mail/you, or
~you/Maildir/)
This module is maintained by the Perl Email Project
To report bugs, please use the request tracker at http://rt.cpan.org. For all other information, please contact the PEP mailing list (see the wiki, above) or Ricardo SIGNES.
Copyright 2003 by Simon Cozens
Copyright 2004 by Casey West
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Email-LocalDelivery documentation | Contained in the Email-LocalDelivery distribution. |
package Email::LocalDelivery; use strict; use File::Path::Expand qw(expand_filename); use Email::FolderType qw(folder_type); use Carp; use vars qw($VERSION); $VERSION = '0.217';
sub deliver { my ($class, $mail, @boxes) = @_; croak "Mail argument to deliver should just be a plain string" if ref $mail; if (!@boxes) { my $default_unixbox = ( grep { -d $_ } qw(/var/spool/mail/ /var/mail/) )[0] . getpwuid($>); my $default_maildir = ((getpwuid($>))[7])."/Maildir/"; @boxes = $ENV{MAIL} || (-e $default_unixbox && $default_unixbox) || (-d $default_maildir."cur" && $default_maildir); } my %to_deliver; for my $box (@boxes) { $box = expand_filename($box); push @{$to_deliver{folder_type($box)}}, $box; } my @rv; for my $method (keys %to_deliver) { eval "require Email::LocalDelivery::$method"; croak "Couldn't load a module to handle $method mailboxes" if $@; push @rv, "Email::LocalDelivery::$method"->deliver($mail, @{$to_deliver{$method}}); } return @rv; } 1; __END__