SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sweet Little Email Validation Script

    http://www.zend.com/codex.php?id=449&single=1

    This bad boy will not only validate an email address by looking at it's format, but it'll connect to the person's server and verify it.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    SitePoint Evangelist worksdev's Avatar
    Join Date
    Mar 2002
    Location
    Central, PA - originally from Monterey, CA
    Posts
    497
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Aspen.

    Great tip.

    I have a use for this for a client right now.

    Best Regards.
    Church Website Design by Enlighten Web Services -
    Web design-hosting-support for Christian ministries
    Friendly Community of Webmasters
    Christian Websites :: Christian Web Design

  3. #3
    Freelance Web Designer KeithMcL's Avatar
    Join Date
    Oct 1999
    Location
    Dublin, Ireland
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks apen. Have saved that for future use

  4. #4
    SitePoint Addict mak-uk's Avatar
    Join Date
    Dec 2001
    Location
    Midlands, UK
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Quick query, how is that function SnowCheckMail used?

    Thanks.

    Mak

  5. #5
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The syntax checking isn't so hot. For example, it rejects info@mycompany.info. A better one (I think) can be found here: http://www.nbrandt.com/email_validation.txt

    See also: http://www.sitepoint.com/article/1051 for another approach
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise

  6. #6
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The syntax checking isn't so hot. For example, it rejects info@mycompany.info. A better one (I think) can be found here: http://www.nbrandt.com/email_validation.txt

    See also: http://www.sitepoint.com/article/1051 for another approach
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise

  7. #7
    SitePoint Zealot rae's Avatar
    Join Date
    Apr 2003
    Location
    bedroom :P
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi!

    I read that code. And ok, we may change the syntax check.
    And I have 2 questions.

    1.: It seems to me, that it really identify the user. Not just the domain. Am I wrong? I didn't see anything like this before.
    Is it really possible? That would be the most precise validation.

    2.: And the second question is:
    Can anybody give me an url or something( how to find these with google ) where I can read about these "socket messages". I'm not "specialized" about sockets. And I need a good reference about making socket connections with mail servers. What commands can I send, what can I get.

    Thanks for the link, and thanks your help in advance! I need this stuff, but I have no clue where to get info about that.
    d(o.O)b -- Notice: undefined variable: /me

  8. #8
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The most important part of this post is the bottom of it. But first things first!

    Alright, that eregi at the beginning is kind of weak, however, that part is super-easy to change.

    First, the slower eregi, can be switched out for the faster preg:
    Code:
    (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*
    @[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$Email))
    // to:
    (!preg_match('#^[_a-z0-9-]+(?:\.[_a-z0-9-]+)*
    @[a-z0-9-]+(?:\.[a-z0-9-]+)*(?:\.[a-z]{2,3})$#i',$Email))
    
    note: I hate it when long code forces the entire thread to get too wide,
    so I put in a line break before each "@". Cut and pasters should remember 
    to remove that line break. :-)
    Hope I did that correctly, didn't look like much needed changing.
    Second, the {2,3} represents {minimum,maximum} number of characters in the top level domain and you can change either of those to whatever you want. For a minimum of 2, max of 4 use {2,4}. Leave the second number out (keep the comma!) and any length will be allowed. {2,}

    On an probably unnecessary efficiency tip, the splitting section of the code could have been replaced by a match in the regex, probably would have been faster since the regex had to be done anyhow. Another reason to use preg.

    Anyway, that tip is probably unnecessary because it is going to be the socket connection to the other server that will slow things down to a factor far greater than the time that regex and split would take.

    This email validation script will yield false positives. Go ahead and try, the example of this code in action is here: http://mailzine.hellophp.com/test/mail_example_en.html
    Put in (I don't know) thisCodeYeildsFalsePositives2132@yahoo.com or whatever else you want @yahoo.com and you'll get a good email address report. I think some email servers will accept anything and then decide what to do with it later.

    I checked some earthlink.net addresses and those worked alright, so it at least works some of the time.

    Oh, just tried aol.com and I'm getting false negatives (in other words, correct addresses being diagnosed as invalid), that's a big problem. Check it out, it's probably just one or two server types or something that have to be excluded from the address check.
    Last edited by samsm; Nov 16, 2003 at 01:58. Reason: ++clarity
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •