procmail
[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:

#------------------------------------------------------------
#  DOMAIN.com Directory Move
#------------------------------------------------------------

  :0 fw
  * ^To:(_dot_)*\(_at_)domain\(_dot_)com
  |sed -e 's/^Subject:[   ]*/Subject: [DOMAIN] /'
  $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
   $DOMAIN

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

   :0 iw: $DOMAIN$LOCKEXT
   * ^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"

   :0A:
   $DOMAIN

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.

Dallman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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