procmail
[Top] [All Lists]

Re: Adding custom mail headers via a filter?

2002-10-24 21:41:59
I'm noticing that with the following two rules.

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

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

Note filtmail is not a filter this time so the only variable at play is exit status.

Anyway, I'm currently seeing that any mail going through strip_attachments.pl
get it's _whole_ From_ removed thus totally confusing my MUA.

Is it a known procmail problem with the _entire_ From_ goes missing rather than
just the easily correctable first character?

This is the strip_attachments filter again

#! /usr/bin/perl5 -w

use lib "$ENV{HOME}/lib/perl5/site_perl";

use IO::Scalar;
use MIME::Parser;
use MIME::Entity;

my $parser = MIME::Parser->new;

$parser->output_to_core(1);
$parser->tmp_to_core(1);

#$envelope = <STDIN>;

my $ent = $parser->parse(\*STDIN);

if ($ent->effective_type eq "multipart/mixed" &&
        $ent->parts == 2 &&
        $ent->parts(0)->effective_type eq "text/plain" &&
        $ent->parts(1)->effective_type eq "application/ms-tnef") {

        my $newent = MIME::Entity->build(Data =>
                        $ent->parts(0)->body_as_string .
                        "\n\n[[WINMAIL.DAT removed]]\n");

        $ent->parts([$newent]);
        $ent->make_singlepart;
        $ent->sync_headers(Length => 'COMPUTE', Nonstandard => 'ERASE');
        #$ent->dump_skeleton(\*STDERR);
}
if ($ent->effective_type eq "multipart/alternative" &&
        $ent->parts == 2 &&
        $ent->parts(0)->effective_type eq "text/plain" &&
        $ent->parts(1)->effective_type eq "text/html") {

        my $newent = MIME::Entity->build(Data =>
                        $ent->parts(0)->body_as_string .
                        "\n\n[[HTML alternate version deleted]]\n");

        $ent->parts([$newent]);
        $ent->make_singlepart;
        $ent->sync_headers(Length => 'COMPUTE', Nonstandard => 'ERASE');
        #$ent->dump_skeleton(\*STDERR);
}

#print $envelope;
$ent->print;

Here's a set of headers I just got for a message from Amazon

Return-Path: <ems+RYNVLFFJ3ZJACD(_at_)bounces(_dot_)amazon(_dot_)com>
Delivered-To: robert(_at_)elastica(_dot_)com
Received: (qmail 98135 invoked by uid 19226); 25 Oct 2002 00:43:14 -0000
Received: from unknown (HELO mm-outgoing-101.amazon.com) ([207.171.188.101]) (envelope-
sender <ems+RYNVLFFJ3ZJACD(_at_)bounces(_dot_)amazon(_dot_)com>)
          by 192.220.75.26 (qmail-ldap-1.03) with SMTP
          for <robert(_at_)elastica(_dot_)com>; 25 Oct 2002 00:43:14 -0000
Received: from mail-ems-104.amazon.com by mm-outgoing-101.amazon.com with ESMTP
        (crosscheck: mail-ems-104.amazon.com [10.16.42.233])
        id RAA-22748640-00970; Thu, 24 Oct 2002 17:43:26 -0700
Received: by mail-ems-104.amazon.com
        id AAA-22748640-30986,30; 24 Oct 2002 17:43:23 -0700
Date: 24 Oct 2002 17:43:23 -0700
Message-ID: 
<.AAA-22748640-30986,30(_dot_)1035506603(_at_)mail-ems-104(_dot_)amazon(_dot_)com>
X-AMAZON-TRACK: 22748640
To: robert(_at_)elastica(_dot_)com
From: "Amazon.com" <music-store-news(_at_)amazon(_dot_)com>
Subject: Save $1.99  on Meat Beat Manifesto's "RUOK?"
Bounces-to: ems+RYNVLFFJ3ZJACD(_at_)bounces(_dot_)amazon(_dot_)com
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-length: 1887


On Wednesday, October 16, 2002, at 10:43  PM, David W. Tamkin wrote:

Bart suggested to Robert,

| :0
| | sed '1s/^rom/From/'

Better,

 :0hf
 * ^^rom( )
 | sed '1s/^rom/From/' # or heck, sed 1s/^/F/



_______________________________________________
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