meonkeys has asked for the wisdom of the Perl Monks concerning the following question:

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.

---
"A Jedi uses the Force for knowledge and defense, never for attack."

Replies are listed 'Best First'.
Re: Email::Filter hello world
by hsinclai (Deacon) on Aug 15, 2004 at 06:31 UTC
    procmailrc errors from a piped command are considered temporary delivery failures by the mta, and a) are probably requeued, and b) procmail tries to "rescue" the failure, dumping the stream back into the delivery pipeline..

    I believe you can add i to the recipe to make it ignore error codes.. so..
    :0fwi

    I wonder if $mail->reject; needs to have  $mail->exit set to work properly ..?

    update - I got it to work with .forward, with contents:
    "|exec /home/privbot/bin/filt.pl"
    it actually generated a bounce back to the sender.

    Notice the pod doesn't mention procmail :) I don't think it works with procmail at all because procmail receives the reject("message") as well as the exit code (constant in Filter.pm) sent by Filter but either tries to recover the "failed" filter and delivers anyway, or depending on what flags are used, just silently stops the pipeline - never does it generate a bounce.. I tried it with many different combinations of procmail flags, even going as far as strace-ing procmail (which revealed nothing except for a successful looking finish).

    At least trying .forward with exec should work.. for $mail->reject

    I did get all the other methods in Email::Filter to work through procmail though...