At 17:45 2010-03-18 -0700, Komal Tagdiwala (ktagdiwa) wrote:
I have a requirement to check the Cc field for a given list of addresses
which, if found, should be appended to the To: field.
Sillyness. Why?
Here s how my recipe currently works:
[snip]
I note that no effort is made to _remove_ the corresponding addresses from
the Cc:.
| /opt/local/bin/formail -i "To: $TO; user1(_at_)someserver\(_dot_)com"
Why are you separating the addresses with a semicolon? You should be using
a comma. The dot in the address needs escaping only when used in a regular
expression.
Have you considered what will happen if there IS NO To: header (and thus
$TO is either empty, or set to a potential prior value, if you have a large
procmailrc)?
The above recipe works just fine as long as I have a single Email address
being searched for in the Cc field. However, if I were to extend this
recipe to check for more than 1 address in the Cc field, I don t know how
to find out which address matched in the Cc condition in order to be able
to add that specific matched address to the To field.
That's easy enough - so long as there's only ONE address. If you have
multiple addresses that may all be present together in various combinations
(and perhaps with intervening addresses which are not of interest), you're
going to need to beef up the processing. I'm not doing that for you here.
Perhaps someone needs to ask "why does this address resassignment need to
take place?"
Below is what I want to do.
*^(Cc):.*(\< user1(_at_)someserver\(_dot_)com|\< user2(_at_)someserver\(_dot_)com|\<
user3(_at_)someserver\(_dot_)com|\< user4(_at_)someserver\(_dot_)com)
*^Cc:.*[ \<]\/(user1|user2|user3|user4)@example\.com
Lose the parens around Cc - while they don't break anything, they also
don't contribute anything to the expression.
I moved the leading space and bracket out to BEFORE the match operator. I
also optimized the expression on the assumption that the domain was in fact
consistent across all the usernames - if they're not, then longhand it much
the way you did originally (but without bracket and space in each address
grouping).
If there's a match, MATCH will be assigned a value like "user1(_at_)example(_dot_)com"
(no quotes, no escaping).
You might benefit from following the link in my .sig and retrieving the
"sandbox" files I have published - it makes it very easy to throw a series
of test messages at a filter and see what would happen, then tweak and re-do.
I can t use the $MATCH variable since I can t use the RegEx operator \/ in
this scenario. Can I?
What would give you the impression that you cannot?
Question: How do I find out which of the above 4 addresses matched in the
Cc condition?
By using MATCH.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
____________________________________________________________
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