procmail
[Top] [All Lists]

Re: forwarding MIME encocded attachments

2000-02-23 10:54:42
On Wed, 23 Feb 2000 12:31:57 -0500 (EST), Errol Casey
<errol(_at_)pobox(_dot_)com> wrote:
I have the following recipie in use to forward a copy of all mail
received, to another account with the subject changed to have
[cadamin] prepended to the subject. Problem is, if email has
attachments I'm just getting a message with the subject only.

How can I modify the recipie to forward all attachments also.

MSGSUBJECT=`/hwtools/bin/formail -zxSubject:`
0 h c
| $MAILX -s "[cadadmin]$MSGSUBJECT" 
gcasey(_at_)somehwere(_dot_)in(_dot_)world

You're not telling us what MAILX is set to, but it is readily apparent
that you are only passing in the headers anyhow.

First off, lose the h flag.

If that alone doesn't help, try something less mysterious than MAILX.
It may not know how to deal with MIME messages at all, or doing
something weird to MIME messages. I would perhaps suggest something
like this:

    :0c
    | formail -I "Subject: [cadadmin]$MSGSUBJECT" \
      | $SENDMAIL $SENDMAILFLAGS gcasey(_at_)somewhere(_dot_)in(_dot_)world

Probably your MAILX is overwriting the original headers, while
Sendmail will pass along anything more or less verbatim (as long as it
looks superficially like an RFC822 message -- additional Received:
headers will, of course, get added along the way). If you need your
destination address to be visible in the headers (e.g. for spam
filtering purposes) you will have to add that explicitly as well.
Perhaps like this:

    :0c
    | formail -I Cc: -I Bcc: -I Resent- -I "To: 
gcasey(_at_)somewhere(_dot_)in(_dot_)world" \
        -I "Subject: [cadadmin]$MSGSUBJECT" \
      | $SENDMAIL $SENDMAILFLAGS -t

The extra Cc: and Bcc: and Resent-* voodoo is because we are using
Sendmail's -t flag, which tells it to specifically use the message's
own headers for information about where to send it. That means we
can't leave in any old recipient headers, because then we'd end up
resending the message to people who have already received it once.
(This may seem like a theoretical thing, but trust me, you will regret
it if you fail to cover this right from the start.)

Finally, you can optimize this a bit by extracting the Subject header
using a MATCH grab, but that is something which has been rehashed
repeatedly on this list recently, so I refer you back to the archives
for more information. A good searchable archive of this list is at
<http://www.rosat.mpe-garching.mpg.de/mailing-lists/procmail/>
(although the search engine sort of sucks. Or maybe I'm just too dense
to figure out how to use it properly).

Hope this helps,

/* era */

What's a "recipie"? A pie you are the recipient of? A reciprocal
approximation of 3.141592653589793...?

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

<Prev in Thread] Current Thread [Next in Thread>