procmail
[Top] [All Lists]

Stripping headers - Request for guidance

2006-01-09 09:32:00
Greetings,

I am currently running a small mail-to-news gateway as an easy way to
manage several large mail lists for some of our users (a la gmane), but
I am running into issues inserting those messages into INN as gmane has
already placed its own headers in the message, e.g. X-Complaints-To. 

In light of that, I am looking for an easy way to strip out the headers
which cause the errors, and I initially came up with the following:

#  Ruby Talk
:0
* ^X-ML-Name: ruby-talk
{
        :0 fwh
        | formail -kz \
                -X Subject: \
                -X In-Reply-To: \
                -X Content-Type: \
                -X MIME-Version: \
                -X Content-Transfer-Encoding: \
                -X Content-Disposition: \
                -X Message-ID: \
                -X References: \
                -X From: \
                -X To: \
                -X Date:

        :0 A
        ! $NNTP(_dot_)comp(_dot_)lang(_dot_)ruby(_dot_)general(_at_)$NNTPEND
}

That works, but I am wondering if it might be easier to
somehow strip out only the offending headers (rather than whitelisting
the allowed headers).  In searching for solutions in that direction, I
found this post from Sean which rewrote a header:

        OLDFROM=|formail -xFrom:

        :0hf
        | formail -I "From:" -I "X-FC-Forwarded-From: $OLDFROM"

I tried something like that for one of the lists, a la:

        # Asterisk Users
        :0 
        * ^X-BeenThere: asterisk-users
        {
                XCOMP=|formail -xX-Complaints-To:

                :0 hf
                | formail -I "X-OLD-Complaints-To: $XCOMP"

                :0 A
                ! 
$NNTP(_dot_)comp(_dot_)telephony(_dot_)pbx(_dot_)asterisk(_dot_)user(_at_)$NNTPEND
        }

With this, I find that the XCOMP= assignment is tried for each message
(from any list) regardless of whether the X-BeenThere matches and I am
therefore getting an error message generated for each message which
passes that point.

Elsewhere, I found the following from Timo:

        #Let's test stripping lines from the email message's header
        :0 fwh
        | egrep -vi "(^Content-|^MIME-Version:.)" 

This would be ideal, but I would like input from the experts as to what
they think the easiest ( while stressing the server the least) method of
achieving my goal.  If it turns out the whitelisting method is best, is
there a way to consolidate the list (or make it a function) so that I can
keep the list of headers in one variable to make changes easier?  

It would be nice to do the procedure on each list through one
call/procedure, but the mail2news gateway requires the name of the group
be used as part of the address.

Any assistance is appreciated.

SWS


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>
  • Stripping headers - Request for guidance, S. William Schulz <=