procmail
[Top] [All Lists]

Re: How to send the original after filter?

2003-08-28 08:37:22
On Thu, 28 Aug 2003, Udi Mottelo wrote:

:0 bf
| lynx -stdin -dump

:0 B
* Viagra
$JUNK

      In this case, if the message is not SPAM the body has been
      already corrupted by lynx.  Any idea how to send (recover?)
      the original HTML message if "Viagra" is not found?

The only way is to save a copy of the original on disk before you begin
filtering.  I generally use an MH-format directory for this because it
simplifies cleanup/recovery if something goes wrong.

The following hasn't been tested but should give you an idea.

CAPTURE=/tmp/$LOGNAME.procmail/.

# Capture the message
:0c
$CAPTURE

ORIGINAL=$LASTFOLDER

# Run filters that may mangle the content
JUNKMAIL=

:0 bf
| lynx -stdin -dump

:0 B
* Viagra
{ JUNKMAIL="Found banned word Viagra" }

# Recover the original message
:0 ifhb
| cat $ORIGINAL

:0e
{
 # Do error recovery here ...
}

:0a
* ? rm $ORIGINAL
{ }

# Deliver as appropriate
:0
* ! JUNKMAIL ?? ^^^^
$JUNK


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail