Click here to get back home

Email::Filter hello world

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Email::Filter hello world Adam Monsen 08-15-2004
Posted by Adam Monsen on August 15, 2004, 3:36 pm
Please log in for more thread options
Is this a good place to ask for help for Email::Filter? If not, where?
I tried http://perlmonks.org/?node_id=383056 but noone really knows as
of yet. Here's my query:


I'm unable to get the simplest example to work with Email::Filter.
This could be due to any number of non-Perl-related things, so if it's
offtopic I apologize (and would love suggestions on where this
question should be asked).

First off, the code:

#!/usr/bin/perl -w
use strict;
use Email::Filter;
my $mail = Email::Filter->new;
$mail->reject;

The preceding code belongs to a user named 'embo' and is stored in the
executable file /home/embo/bin/filt. Here is embo's ~/.procmailrc:

MAILDIR=$HOME/Mail
LOGFILE=$MAILDIR/from
LOGABSTRACT=all
VERBOSE=off

##### backup every incoming email
:0 c
backup

##### filter with Mail::Audit
:0fw
| /home/embo/bin/filt

When I try to send a test email from adamm to embo on the same system
using date | mail embo, here's what I see in /home/embo/Mail/from...

procmail: Program failure (100) of "/home/embo/bin/filt"
procmail: Rescue of unfiltered data succeeded
From adamm@localhost.localdomain Sat Aug 14 21:30:22 2004
Folder: /var/mail/embo 658

I would expect that email to bounce back to adamm, but adamm receives
no bounce. embo still receives the email from adamm in his mail spool.
Anyone have any idea what I'm doing wrong? The pod for Email::Filter
is pretty weak in terms of implementation. I also tried a ~/.forward
file containing only |/home/embo/bin/filt; no luck there.

In return for help with Email::Filter, I offer the following (all
mentioned software will be Free, as in speech):
* documentation, including:
+ custom-made Email::Filter "Hello World" tutorial hosted at
http://adammonsen.com/tut/
+ POD to add to Email::Filter
* email vacation autoresponder software


Posted by chris-usenet on August 16, 2004, 1:24 pm
Please log in for more thread options
> I'm unable to get the simplest example to work with Email::Filter.
> First off, the code:
> #!/usr/bin/perl -w
> use strict;
> use Email::Filter;
> my $mail = Email::Filter->new;
> $mail->reject;

Running this as a forwarding filter will cause the MTA to reject the
inbound email ($mail->reject exits with status 100).

> The preceding code belongs to a user named 'embo' and is stored in the
> executable file /home/embo/bin/filt. Here is embo's ~/.procmailrc:
[...]
> ##### filter with Mail::Audit
> :0fw
> | /home/embo/bin/filt

OK, so you're telling procmail to use your program as a filter, i.e. the
program's output will be used by procmail to replace the original input.

> When I try to send a test email from adamm to embo on the same system
> using date | mail embo, here's what I see in /home/embo/Mail/from...

> procmail: Program failure (100) of "/home/embo/bin/filt"
> procmail: Rescue of unfiltered data succeeded
> From adamm@localhost.localdomain Sat Aug 14 21:30:22 2004
> Folder: /var/mail/embo 658

Yes that's expected. Procmail has fed the email to your filter ("f"). Your
filter has exited with an error status ($mail->reject). Procmail figures
that your filter has barfed somewhere, so it abandons the result and
continues as if your program had never been run in the first place ("w").

> I would expect that email to bounce back to adamm, but adamm receives
> no bounce. embo still receives the email from adamm in his mail spool.

As per my description, the observed behavious is indeed what I would
have expected to happen.

> Anyone have any idea what I'm doing wrong?

Don't set up your program as a procmail filter. You should be able to
reject messages like this [untested]:

        :0 h
        * ^Subject: bounceme
        EXITCODE=100

> The pod for Email::Filter
> is pretty weak in terms of implementation.

Seems fine to me - I guess it depends on where you're coming from (if
you're conversant with a subject then you don't need many pointers...)

> I also tried a ~/.forward
> file containing only |/home/embo/bin/filt; no luck there.

I would have expected that to have "worked" in so far that all emails
should have been bounced to the sender.

> In return for help with Email::Filter, I offer the following [...]
> * email vacation autoresponder software

Since you're using procmail, why not use procmail's autoresponder
software. Alternatively, why not ditch procmail entirely and use
Email::Filter on its one?

        use Email::Filter;
        my $mail = Email::Filter->new(emegency => '~/emergency_mbox');
        $mail->reject ('Go away!') if $mail->from =~ /badamm@localhostb/;
        $mail->accept ();

Chris


Similar ThreadsPosted
Save your world November 25, 2005, 8:21 pm
A newbee in the world of PERL July 9, 2004, 12:59 am
Filter::Simple bug? December 21, 2004, 9:54 pm
opendocument -> csv filter ? September 20, 2006, 10:28 am
where can download Filter::netcrypt February 22, 2005, 9:55 pm
Perl Tk::FBox and filter argument January 30, 2007, 2:40 pm
Printing xlated output of Filter::Simple ? November 13, 2004, 6:15 pm
can apache::filter work with virtual location? July 28, 2007, 10:36 pm
Converting email December 21, 2004, 6:14 pm
Attaching to an email May 18, 2006, 5:59 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap