Link to home
Create AccountLog in
Avatar of wylde342

asked on

Procmail recipe help - changing/erasing text

We are looking to use a postfix/procmail server to forward incoming messages with attachments to a final destination server.  The goals are:

1.  Keep the subject
2.  Change the sender to us (the from address the final recipient sees)
3.  Delete all the text in the body
4.  Keep the attachment

I am able to do everything except step 3, and have tried quite a lot of ideas using sed.  Does anyone have any ideas?


SUBJ_=`formail -c -xSubject: \
         | expand \
         | sed -e 's/  */ /g' \
         | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`

* ^Subject:.*Message
# Avoid email loops
* ! ^X-Loop:
  :0c:   #Preserve a copy of the email

  :0fwh  #Adjust some headers before forwarding
  | formail -A"X-Loop:" \
            -I"From:" \
            -I"Subject: ${SUBJ_} " \
            # Forward the email

Open in new window

Avatar of arnold
Flag of United States of America image

The text in the body is a combination of attachments.
I.e. the message is in plain text while the attachment follows.
You would need to use mimedefang to separate the attachments, the problem is which attachment type you want i.e. ones that provide a filename while the inline ones you want discarded?

:0 Bfwh will pass the body of the message to a filter You would need to extract the attachment separators from the header.
Avatar of wylde342



If I wanted to just remove the plain text - how would I do that?
Avatar of arnold
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Awesome - thank you for the info Arnold.