procmail
[Top] [All Lists]

Re: Appending text to subject line

2000-02-07 07:31:39
On Sun, 06 Feb 2000 14:21:44 -0600, Tom Adler <adlertom(_at_)execpc(_dot_)com>
wrote:
I currently have a procmail recipe that forwards a copy of my
e-mail to a second e-mail address. I would like to append a short
string of text to the subject line of each forwarded message. My
recipe is something like this:
:0c
!secondaddress(_at_)isp(_dot_)com
How would I, for example, add the text "xyz" to the end of the
subject line of the forwarded message?

This is pretty much a FAQ, although I'm not sure you would be able to
locate it in its current form in the FAQ. (Hmm.)

    :0
    | script which modifies standard input and writes it to standard output \
      | $SENDMAIL $SENDMAILFLAGS secondaddress(_at_)isp(_dot_)com

In this case, the canonical script needs a condition to go with it:

    :0
    * ^Subject:[        ]*\/[^  ].*
    | formail -I "Subject: [newstring] $MATCH" \
      | $SENDMAIL $SENDMAILFLAGS secondaddress(_at_)isp(_dot_)com

Cautions: This will only work for mail with a non-blank Subject. Mail
with an empty Subject: will need to be treated separately. And as
usual, the whitespace in the square brackets consists of a space and a
tab (in no particular order).

FWIW, the FAQ is at <http://www.iki.fi/era/procmail/mini-faq.html>

/* era */

-- 
 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