procmail
[Top] [All Lists]

Re: address/domain matching question

2003-04-04 09:10:17
[fixed top posting]

On  4 Apr, Jason Crowe wrote:

| ----- Original Message -----
| From: "Jason Crowe" <jcrowe(_at_)midwestglove(_dot_)com>
| To: <procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE>
| Sent: Wednesday, April 02, 2003 9:57 AM
| Subject: address/domain matching question
| 
| 
| > Here is my recipe segment:
| > -------------------------------------------------------
| > FRIENDS=/etc/procmail/friends
| > :0
| > * ? (formail -x From: -x Sender: -x Resent-From: | fgrep -iqf $FRIENDS)
| > -------------------------------------------------------
| > What can I do to this recipe to have it match user(_at_)domain1(_dot_)com or
| > @domain2.com?
| >
| > There are some time I want to match an entire domain, but others I want to
| > match only the single address for a domain.
| >
| > Example:
| > I want to match customer(_at_)hotmail(_dot_)com but not 
spam(_at_)hotmail(_dot_)com
| >
| > This is what this currently will do if customer(_at_)hotmail(_dot_)com is 
in the
| > $FRIENDS file.
| > I would also like this to match entire domains that  are legit, like
| > @customer.com
| >
| > Is it possible to use both formats from the same $FRIENDS file?
| [snip]
| 
| 
| Is this not possible, or is this a stupid question?

In the 2 days you waited, you could've had the answer.  In fact, in
less time than you took to compose the first message, you could've had
your answer.

Go to a directory suitable for testing.  Put a test message or messages
in it.  Create a $FRIENDS file there with some patterns you want to
test, so it can be modified without affecting the original. Create a
file, testrc, that looks like:

---(cut here)---
DEFAULT=/dev/null
FRIENDS=./friends.file
NL="
"

:0
* ? (formail -x From: -x Sender: -x Resent-From: | fgrep -iqf $FRIENDS)
{ LOG = "Matched$NL" }

# optionally
:0E
{ LOG = "No match$NL" }

HOST
---(cut here)---

Edit your test message(s) to include headers you expect/don't expect to
match and run them through testrc like:

procmail ./testrc <test.msg

Since no LOGFILE is set, output will be to the terminal you're on
(stderr).  Test until satisfied.

As far as all this goes, it's not specifically a procmail question. 
Simple testing like "echo 'From: whatever' |fgrep -iqf $FRIENDS would've
told you what you wanted to know.  Or, for completeness' sake, you feed
test messages to your entire formail | fgrep pipeline without even
creating a testrc.  But the testrc method is a useful one to have in
your arsenal for more complicated procmail recipe testing. 

Unsolicited hint: there's no requirement that fgrep be used.  I use
different greps with different options for different purposes,
including extended regular expressions stored in -f files.

-- 
Email address in From: header is valid  * but only for a couple of days *
This is my reluctant response to spammers' unrelenting address harvesting



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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