Link to home
Create AccountLog in
Avatar of wylde342
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?

/bin/bash

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



:0
* ^Subject:.*Message
# Avoid email loops
* ! ^X-Loop: user@gmail.com
{
  :0c:   #Preserve a copy of the email
  Infolist.mail

  :0fwh  #Adjust some headers before forwarding
  | formail -A"X-Loop: user@gmail.com" \
            -I"From: us@ourcompany.com" \
            -I"Subject: ${SUBJ_} " \
	           
            # Forward the email
  :0
  !user@gmail.com
}

Open in new window

Avatar of arnold
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
wylde342

ASKER

Arnold,

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

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