Mail-Procmail
view release on metacpan or search on metacpan
#!/usr/bin/perl -w
use strict;
use Mail::Procmail;
pm_init(logfile=>'stderr', loglevel=>3);
if ( pm_gethdr("subject") =~ /interesting topic/i ) {
pm_resend("my_friend@somewhere.com", continue => 1);
pm_deliver($ENV{HOME}."/Mail/interesting");
}
# Default delivery.
pm_deliver("/var/spool/mail/".getpwuid($>));
As can be deduced from the pm_init call, logging will be done to
standard error. If a suitable message comes along, the following
information will be logged:
2000/08/08 21:23:55 Mail from John Doe <jdoe@spam.net>
2000/08/08 21:23:55 To: jvromans@squirrel.nl
2000/08/08 21:23:55 Subject: This is an interesting topic
2000/08/08 21:23:55 resend[6]: my_friend@somewhere.com
2000/08/08 21:23:55 deliver[7]: /home/jv/Mail/interesting
examples/filter.pl view on Meta::CPAN
#!/usr/bin/perl -w
use strict;
use 5.005;
my $TMPDIR = $ENV{TMPDIR} || $ENV{TEMP} || '/usr/tmp';
# The default mailbox for delivery.
my $default = "/var/spool/mail/".getpwuid($>);
# A pattern to break out words in email names.
my $wordpat = qr/[-a-zA-Z0-9_.]+/;
my $wordpat_nodot = qr/[-a-zA-Z0-9_]+/;
# Destination for special emails.
sub incoming { $ENV{HOME}."/Mail/Incoming/".$_[0].".spool" }
# Destination for mailing lists.
sub maillist { incoming("maillists.".$_[0]) }
lib/Mail/Procmail.pm view on Meta::CPAN
# Set up. Log everything up to log level 3.
my $m_obj = pm_init ( loglevel => 3 );
# Pre-fetch some interesting headers.
my $m_from = pm_gethdr("from");
my $m_to = pm_gethdr("to");
my $m_subject = pm_gethdr("subject");
# Default mailbox.
my $default = "/var/spool/mail/".getpwuid($>);
pm_log(1, "Mail from $m_from");
pm_ignore("Non-ASCII in subject")
if $m_subject =~ /[\232-\355]{3}/;
pm_resend("jojan")
if $m_to =~ /jjk@/i;
# Make sure I see these.
lib/Mail/Procmail.pm view on Meta::CPAN
=head2 pm_deliver
This routine performs delivery to a Unix style mbox file, or maildir.
In case of an mbox file, the file is locked first by acquiring
exclusive access. Note that older style locking, with a lockfile with
C<.lock> extension, is I<not> supported.
Example:
pm_deliver("/var/spool/mail/".getpwuid($>));
Attributes:
=over
=item *
continue
If true, processing will continue after delivery. Otherwise the
( run in 0.306 second using v1.01-cache-2.11-cpan-8d75d55dd25 )