procmail
[Top] [All Lists]

Header insertion from message body...

1999-11-29 15:39:20

I've started using one of these web based email accounts as a way to get
at my email when I'm travelling. Unfortunately, these email web clients
don't allow me to add arbitrary headers to my outgoing email, in
particular, a Reply-To: header so that email responses don't go to the
web account but to my super-duper procmail enabled primary account. 

My solution was to send specially tagged email to myself with header
information in the body of the message, have procmail add these headers
(including the real To: header) to the message header of the message,
and forward it on. 

Currently, the implementation looks like this:

:0
* [ Check for specially tagged messages from my web account... ]
{
:0 fBD
* ^\/Reply-To:.*
| formail -i "$MATCH"

:0 af
| sed -n -e '1,/^$/ p' -e '1,/^$/ d' -e '/^Reply-To:.*/ d' -e 'p'

[ similar rule pairs for To:, Cc:, and Bcc. ]

:0 D
* ! [ To: field unchanged ]
* ! [ To: field empty ]
| $SENDMAIL -t

EXITCODE=65
HOST=drop.mail.that.gets.to.here.and.bounce
}

I'd really like this to work for arbitrary headers, or at least not
force me to change the script when I decide I need a new header I hadn't
thought of before. My attempt at this looked something like this:

:0
* [ Check for specially tagged messages from my web account... ]
{
  :0 fBD
  HEADERS=| formail -b -c -f -X "" \
    | sed -n -e 's/^\(.*\)$/-i "\1"/' -e 'H' -e '$ x' -e '$ p' \
    | tr '\012' ' '

  :0 f
  | formail $HEADERS
}

but it seemed to be impossible to get the quoting right for the HEADERS
variable. Either header fields would be broken up at spaces, despite the
embeded quotes, or the entire command arguement string would be
considered one arguement. 

There are a few other problems with my approach above, only the first
header field in the body is inserted into the header of the message, but
_all_ matching header fields are deleted from the message body. 

Ideally, I'd like my secondary message body "header" be delineated by
empty lines at top and bottom and for the rest of the message to be
untouched. ie. 

   From fjdkalfjl foo bar baz
   Subject: Send this on, will ya?
   To: me

   Reply-To: my real account dummy
   From: Phantom remailer
   To: The real destination

   Anything here is ignored, and become the new message body. Even
   Reply-To: this really shouldn't be touched. 
   Get the idea?

As it is, my current solution works, but it offends me that I couldn't
get a more general solution working. Additional implementation
constraints: I'd prefer not to use temporary files or recursive
INCLUDERC assignments if possible. 

Thanks for any help.

Cheers!

nathan

P.S. I'm using procmail version 3.11 pre 7 on a SunOS 4.1.? box, 
     soon to be Solaris 2.7 box. Not my system (anymore) so I've 
     got to work with what I've got. 

-- 
---------------------------------------------------------------------
                                 as ci   Field of Operations Research
Nathan Edwards                  imapofa            Cornell University
nedwards(_at_)orie(_dot_)cornell(_dot_)edu       ustrali               Ithaca 
NY 14853
www.orie.cornell.edu/~nedwards       a                      
---------------------------------------------------------------------

<Prev in Thread] Current Thread [Next in Thread>
  • Header insertion from message body..., Nathan Edwards <=