[Top] [All Lists]

Re: Subject Rewrite and Move

2007-01-13 13:58:13
On Sat, Jan 13, 2007 at 03:16:35PM -0500, CT Guy wrote:
I have the following in my recipe:

# Directory Move

  :0 fw
  * ^To:(_dot_)*\(_at_)domain\(_dot_)com
  |sed -e 's/^Subject:[   ]*/Subject: [DOMAIN] /'

The $DOMAIN is set properly.  The log shows that |sed... is being
processed, but the $DOMAIN instruction is being bypassed and mail is
going into the inbox.

Am I missing something?

You can only have one action-line on a recipe.  You've used yours
up with the sed pipe.  You can resolve this a couple of ways.
One, use a subsequent recipe with an "A" flag:

   :0 fw hi
   * ^To:(_dot_)*(_at_)domain\(_dot_)com
   |sed -e 's/^Subject:[   ]*/Subject: [DOMAIN] /'

   :0 A:   # use the colon for lockfile unless $DOMAIN is a dir

(Note, also, the "i" flag I added.  You may find you need
it, to stop the pipe from closing prematurely on long messages.
The "h" flag causes the change only to apply to the header;
don't bother piping the whole message through sed!
Oh -- and you don't need to quote the "@" sign.)

Or, two, do your original recipe this way:

   * ^To:(_dot_)*(_at_)domain\(_dot_)com
   |sed -e 's/^Subject:[   ]*/Subject: [DOMAIN] /' >> $DOMAIN

Oh, and what happens if the message has no Subject?

By the way, you could also use formail to rewrite the
Subject.  Probably slightly less work for your server.

   MATCH   # clear the var
   :0 fw hi
   * ^To:.*domain\.com
   * ^Subject:\/.*
   | formail -i "Subject: [$DOMAIN]$MATCH"


I love that sed line because I can filter mail into one inbox and
at-a-glance see which email it came from.

Well, you could save to a folder based on the name of the domain,
instead, as an alternative.


procmail mailing list   Procmail homepage:

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