Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 03 Sep 2010 15:02:12 -0400
From:      Glen Barber <glen.j.barber@gmail.com>
To:        Drew Tomlinson <drew@mykitchentable.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Regex Help For Procmail
Message-ID:  <4C814634.1000003@gmail.com>
In-Reply-To: <4C814262.5060504@mykitchentable.net>
References:  <4C814262.5060504@mykitchentable.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Drew,

On 9/3/10 2:45 PM, Drew Tomlinson wrote:
>  I use procmail for mail delivery and I'm trying to concoct the right
> regex to match From: headers and deliver to a folder.  However mail is
> sent from various addresses so I want to match all that end with
> "famous-smoke.com>".  Here's an example of a header:
> 
> From: "Famous Smoke Shop"<Announce@email.famous-smoke.com>
> 
> Because I also occasionally order, I don't want to catch mail from
> anything that has the word "Orders" and "Famous" in the From field. 
> Thus here is my procmail recipe:
> 
> # Deliver order info to inbox
> :0
> *^From:.[Ff]amous.*[Oo]rder.*famous-smoke.com>$
> "${HOME}/Maildir/new/"
> 

Is this supposed to be "match Famous OR Order"?  This currently matches
"Famous AND Order".

> # Deliver other email to folder
> :0
> *^From:.*famous-smoke.com>$
> "${HOME}/Maildir/.Shopping/Famous Smoke/Email/"
> 

Going by your examples, you want to catch "Famous OR Order" and place
that in Maildir/new, and all other email from this address to go to
Maildir/.Shopping/...

Try this:

# catch "famous" or "order"
:0
* ^From:.*([Ff]amous|[Oo]rder).*famous-smoke.com>$
"$HOME/Maildir/new"

# catch everything else from this sender
:0
* ^From:.*famous-smoke.com>$
"$HOME/Maildir/.Shopping/Famous Smoke/Email/"


> According to my procmail log, the From: header does not match.  I would
> expect the example From: header above to match the second regex and be
> delivered to the specified folder. Where is my error?
> 

If my assumption above is incorrect, could you paste a snippet from your
procmail log and point out what should be matching so we can have a
specific example?

Regards,

-- 
Glen Barber



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C814634.1000003>