procmail
[Top] [All Lists]

Re: Adding custom mail headers via a filter?

2002-10-15 03:04:45
Well my filter now performs the following

sub reason {
        my $reason = $_[0];

        print $Headers;
        print "\n";
        print "X-Challenge-Reason: $reason\n";
        print "\n";
        print $Body;
}

and I can see that stdout contains the complete message.

But procmail is seeing the old unchanged message.

Am I understanding things correctly?

I've stepped through in perl and witnessed that this code does execute and stdout
contains the same message with the X-Challenge-Reason added.

Why is procmail not seeing the changed message?

This is what i see when I run my filter in perl

From robertnicholson(_at_)hotmail(_dot_)com Tue Oct 15 09:26:39 2002
Return-Path: <robertnicholson(_at_)hotmail(_dot_)com>
Delivered-To: robert(_at_)elastica(_dot_)com
Received: (qmail 57509 invoked by uid 19226); 15 Oct 2002 09:07:08 -0000
Received: from unknown (HELO hotmail.com) ([64.4.21.95]) (envelope-sender
    <robertnicholson(_at_)hotmail(_dot_)com>)
          by 192.220.75.26 (qmail-ldap-1.03) with SMTP
          for <robert(_at_)elastica(_dot_)com>; 15 Oct 2002 09:07:08 -0000
Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC;
         Tue, 15 Oct 2002 02:09:57 -0700
Received: from 202.133.169.106 by lw14fd.law14.hotmail.msn.com with HTTP;
        Tue, 15 Oct 2002 09:09:57 GMT
X-Originating-IP: [202.133.169.106]
From: "Robert Nicholson" <robertnicholson(_at_)hotmail(_dot_)com>
To: robert(_at_)elastica(_dot_)com
Bcc:
Subject: this is a test
Date: Tue, 15 Oct 2002 02:09:57 -0700
Mime-Version: 1.0
Content-Type: text/plain; format=flowed
Message-ID: <F95fY6SGgHNjUgPBZa3000229e4(_at_)hotmail(_dot_)com>
X-OriginalArrivalTime: 15 Oct 2002 09:09:57.0432 (UTC)
    FILETIME=[A1F34B80:01C2742A]
X-Challenge-Reason: Sender not recognized

this message should be marked as junk

...

That looks prefectly acceptable to me.

But what procmail sees is the original message without "X-Challenge-Reason" header.


I think what might be confusing the issue is I'm guessing that procmail doesn't
consider ? syntax ie.

#let filtmail do the rest
:0 HB
* ? $HOME/.filtmail/filtmail
$MAILDIR/copy

a "filter"

but only

:0 fw
* ^Content-type:.*boundary
| $HOME/perlscripts/strip_attachments.pl

I just tried changing

#let filtmail do the rest
:0 HB
* ? $HOME/.filtmail/filtmail
$MAILDIR/copy

to

#let filtmail do the rest
:0 HBf
* ? $HOME/.filtmail/filtmail
$MAILDIR/copy

and it still didn't work.

Will procmail let me change the content of a message that's sent through the * ? syntax?


On Tuesday, October 15, 2002, at 02:02 PM, Professional Software Engineering wrote:

At 12:53 2002-10-15 +0700, Robert Nicholson did say:
So the claim is that if my filter echos a new message to stdout that procmail will take that as the message?

I suggest you check out the "sandbox" testing method. You could easily answer your own question by writing a simple filter and throwing a test message at it and confirming what it does.

The h and b (lower case) flags define what gets thrown at the filter (default is both), so you can rewrite headers, or you can rewrite the body. Rewriting could be as simple as tacking on a footer, or truncating the body to just a few lines (say you're processing bounce messages and don't want to receive bounced attachments).

In practice, a procmail filter recipe isn't any different than a pipe at the shell.

[big ol' snip]

---
 Sean B. Straw / Professional Software Engineering

Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html> Please DO NOT carbon me on list replies. I'll get my copy from the list.

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

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