Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: regex to validate e-mail addresses and phone numbers

by Limbic~Region (Chancellor)
on Feb 10, 2004 at 14:20 UTC ( [id://327925]=note: print w/replies, xml ) Need Help??


in reply to Re: regex to validate e-mail addresses and phone numbers
in thread regex to validate e-mail addresses and phone numbers

b10m,
While I agree with your suggestion of Email::Valid in principal, it may not be the right solution for the task at hand. I am guessing there is more to this than was originally stated. It might be best to first ask some simple questions:

  • Am I validating inbound, outbound, or bi-directional addresses?
  • Does my inbound MTA comply with the RFCs? If not is it more strict, more relaxed, or bits and pieces of both?
  • Do I care if it is valid? If it "looks" like a spammer, I want to drop it regardless.

    It may turn out that a home-grown regex is the right way to go, it may turn out that Email::Valid or Email::Valid::Loose is the way to go. It may even turn out that the best solution is SpamAssasin.

    Cheers - L~R

    • Comment on Re: Re: regex to validate e-mail addresses and phone numbers
  • Replies are listed 'Best First'.
    Re: Re: Re: regex to validate e-mail addresses and phone numbers
    by makar (Novice) on Feb 10, 2004 at 16:37 UTC
      Forgive my newbieness in asking, but I was taught that using a premade package like Valid is the best solution 99% of the time, and that most of the 1% was for when space/cpu and such were at issue.

      So I am wondering what would make you lean towards a home-grown solution over the module?

      Thank you in advance. ~Adam Marquis
        makar,
        Have you ever heard of an XY problem? It is when someone asks how to do Y when they really want to do X. They ask how to do Y because they believe it is the best way to accomplish X. The people that they ask go through many iterations of "try this", followed by "that won't work because of". I am not suggesting to use something other than Email::Valid if that truly is what is desired. What I am saying that is depending on the circumstance, other solutions may be the way to go.

        For instance, say the problem is receiving spam messages from addresses that include % symbols and @ signs. You believe that it isn't a valid email address since you have never seen it before. You use Email::Valid and you find out that it is very valid and is a common trick for open-relays. Hmmmm - what do I do? You create your own regex that says I do not care if this is valid, no legitimate mail I receive uses this syntax so I am going to get rid of it.

        Cheers - L~R

          Understood, thank you very much.

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: note [id://327925]
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others examining the Monastery: (4)
    As of 2024-04-20 02:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found