Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have found a lot of examples for procmail to match on the From: header with wilcards, but I'd like to do an exact match, in order to prevent From:.*jgordon@example.com matching both jgordon@example.com and bjgordon@example.com

Is this possible, and if so, how?

share|improve this question
add comment

3 Answers

The customary procedure is to add word boundary anchors on both sides of the target address.

:0
* ^From:(.*\<)?jgordon@example\.com\>
...
share|improve this answer
add comment

The .* is what is matching the additional characters. You only need to match spaces after the header name, so you can change this to *.

* ^From: *jgordon@example.com

I suspect that it may also be possible to anchor the end of the header to avoid matching additional characters at the end, but I haven't tested this myself.

* ^From: *jgordon@example.com$
share|improve this answer
    
That will fail to match From: John Gordon <jgordon@example.com> or (in the latter case) From: jgordon@example.com (John Gordon) but this old format is no longer very widely used. –  tripleee Jul 22 '12 at 19:54
add comment

I'm a bit confused. You should have a procmail for each user. If you folded them into the same one, that's the problem. Of course, Unix can handle it! Just tell it how to handle it. Keep in mind that it flows down. So you can squash things as they come in. Hook the bjgordon first.

:0
* To: bjgordon@example.com
bjgordon_file


:0
* To: jgordon@example.com
jgordon_file

If you want it to survive a rule use the carbon copy rule:

:0 c:
* From: root <root@foo.bar.com>
root_foo_mail.`date +%y%m%d`
share|improve this answer
    
I'm trying to use the 'From:' header, that's probably where your confusion comes from? –  datadevil Jul 2 '12 at 13:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.