Email::Filter::Rules(3)User Contributed Perl DocumentatioEnmail::Filter::Rules(3)



NNAAMMEE
       Email::Filter::Rules - Simple Rules for Routing Mail with Email::Filter

VVEERRSSIIOONN
       1.121

SSYYNNOOPPSSIISS
         #!/usr/bin/perl -w
         use strict;
         use Email::Filter;
         use Email::Filter::Rules;

         my $maildir = '/home/jbisbee/mail/';
         my $msg = Email::Filter->new(emergency => $maildir . 'emergency');

         my $mail_lists = Email::Filter::Rules->new(
             rules => '/home/jbisbee/bin/mail_lists'
         );

         if (my $mail_list_folder = $mail_lists->apply_rules($msg)) {
             $msg->accept($maildir . $mail_list_folder);
         }

         $msg->accept($maildir . 'inbox');

       Where the 'rules' can be a filename, array ref, or scalar and looks
       like this

         # DESTINATION FOLDER <space> Email::Filter->$METHOD(S) <space> SUBSTRING

         # Linux - FLUX
         lists/linux/flux/linux        to:cc linux@flux.org
         lists/linux/flux/talk         to:cc talk@flux.org
         lists/linux/flux/website      to:cc website@flux.org
         lists/linux/flux/announce     to    flux-announce@flux.org

         # Linux - Fluxbox
         lists/linux/fluxbox/users     to:cc fluxbox-users@lists.sourceforge.net
         lists/linux/fluxbox/devel     to:cc fluxbox-devel@lists.sourceforge.net
         lists/linux/fluxbox/announce  to:cc fluxbox-announce@lists.sourceforge.net

         # Linux - Debian
         lists/linux/debian/news       to    debian-news@lists.debian.org
         lists/linux/debian/announce   to    debian-announce@lists.debian.org
         lists/linux/debian/mirrors    to    debian-mirrors@lists.debian.org
         lists/linux/debian/bugs       to:cc bugs.debian.org

         # Linux - Mozilla
         lists/linux/mozilla-bugs      to    mozilla-bugs

         # Perl
         lists/perl/useperl            to:cc use-perl

         # Perl - PM
         lists/perl/pm_groups          to:cc pm_groups@pm.org
         lists/perl/pm/southflorida    to:cc southflorida-pm@mail.pm.org

         # Word of the Day
         lists/word-of-the-day from word@m-w.com

DDEESSCCRRIIPPTTIIOONN
       Email::Filter::Rules is a simple way to route e-mail into folders with-
       out having to touch your filter script.  I used to edit my filter
       script often to add or remove e-mail lists and often would fat finger
       something and enter a typo.  This would result in all my e-mail bounc-
       ing and all in all would be a real bummer.

       I wanted to make it syntax simple so it wouldn't end up looking like to
       awful procmail recipe or some cryptic piece of junk.

UUSSAAGGEE
       Simply put, a rule consists of a destination folder, one to many
       Email::Filter method names, and a substring to test the result of the
       method call.

         DESTINATION FOLDER <space> Email::Filter->$METHOD(S) <space> SUBSTRING

       where a rule looks like this

         lists/perl/pm/southflorida    to:cc southflorida-pm@mail.pm.org

       each rule is tested and quotemeta is used on the substring

         $msg->to =~ /southflorida-pm\@mail\.pm\.org/i
         $msg->cc =~ /southflorida-pm\@mail\.pm\.org/i

       and the destination folder is returned for the first matching test

         lists/perl/pm/southflorida

       and now I have the mail folder, I can tell the Email::Filter object to
       accept to that folder.

       So thats it, short, simple, and to the point.  No more boucing e-mails
       by editing my filter directly. :)

CCOONNSSTTRRUUCCTTOORR
       EEmmaaiill::::FFiilltteerr::::RRuulleess-->>nneeww(( rruulleess ==>> $$rruulleess ))


       * rules
           Can be a scalar, array reference, or a file name name.

       * debug
           Boolean to turn on warnings during apply_rules

MMEETTHHOODDSS
       $$eeffrr-->>aappppllyy__rruulleess(( $$eemmaaiill ))

       Pass in an e-mail object and attempt to call methods you defined in
       your rules file on it.

AAUUTTHHOORR
       Copyright 2005 Jeff Bisbee <jbisbee@cpan.org>

CCOOPPYYRRIIGGHHTT
       This program is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

       The full text of the license can be found in the LICENSE file included
       with this module.

SSEEEE AALLSSOO
       Email::Filter, Email::Simple



perl v5.8.8                       2006-11-05           Email::Filter::Rules(3)
