procmail
[Top] [All Lists]

Re: Need some help on regexp

2003-07-28 14:31:43
At 13:58 2003-07-28 -0700, multimedia-fan(_at_)myrealbox(_dot_)com wrote:
I am trying to have procmail check if the From: field is valid.

There are a variety of addressing mechanisms.

This regular expression is working so far in my sandbox, but of course I
am a bit hesitant to go live with it,

You might consider having it live emitting logfile entries rather than taking any action.

Here is what I can think of so far (after reading a bit in several
regexp resources):


^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})

problem: from can come in many forms, including (but certainly not limited to):

        userid(_at_)domain(_dot_)tld
        <userid(_at_)domain(_dot_)tld>
        "name text" <userid(_at_)domain(_dot_)tld>
        userid(_at_)domain(_dot_)tld (name text)

Those last two could have the nametext on the opposite side instead, and there are other forms as well.

It seems that my ISP is unable to install sendmail properly nor would
allow me to have access to build a new sendmail.cf file to prevent
accepting mail from email addresses that are not properly formatted.

I am getting emails from addresses like jokes(_at_)somewhere(_dot_)nowhere

Well, that's an invalid TLD - at least _at_present_.

What is the From_ address? The ENVELOPE sender is what the MTA would be checking for validity. You could extract that and then use the "host" tool to determine if it'll resolve or if there's an MX, etc. My sandbox framework has "common extractions" for the from address and from domain - so it's easy enough to grab the domain portion of the from address and check it.

Now the above catches  jokes(_at_)somewhere(_dot_)now as part of the address and
will still accept it, what can I do to prevent that from happening?
Or did I have the wrong approach?

Wrong approach.  The above regexp is inadequate for the purpose.

---
 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(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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