Email Code

  Home arrow Email Code arrow Email Validation - Gone Wild
EMAIL CODE

Email Validation - Gone Wild
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2003-08-19

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    This function checks the validity of any given e-mail address. It checks ALL CURRENT (as of today, 8.19.03) top level domains. I may have missed one or two, but I think I got them all now! Check it out!

    By : DeadlySin3

    <?php
    function validate_email($str){
    $str = strtolower($str);
    if(ereg("^([^[:space:]]+)@(.+)\.(ad|ae|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|fi|fj|fk|fm|fo|fr|fx|ga|gb|gov|gd|ge|gf|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nato|nc|ne|net|biz|info|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$",$str)){
    return 1;
    } else {
    return 0;
    }
    }

    if(validate_email($email)) { echo "E-mail is valid"; }
    else { echo "Either the e-mail is not valid, or the top level domain is not included in the email validation list."; }
    ?>

    <?php
    /* Comments
    You don't need this portion to use the script.
    You may safely delete this
    To test it out for fun, you could upload this script to your server...

    point your browser to it
    http://www.YOURSITE.com/scriptName.php

    and append this to it: ?email=me@you.net
    so it looks like this
    http://www.YOURSITE.com/scriptName.php?email=me@you.net

    This would give the output: E-mail is valid

    Since "net" is in the above list.. it returns 1 (true)

    then try this

    http://www.YOURSITE.com/scriptName.php?email=notValid@all.mistake

    this would return 0 (false):
    Either the e-mail is not valid, or the top level domain is not included in the email validation list.

    It returns 0 because "mistake" isn't in the list above.

    To update the list, just add new extensions to the list above when they become available!

    Hope ya like it

    */

    ?>



    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Email Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    EMAIL CODE ARTICLES

    - Basic Ajax contact form
    - Random validation image
    - tinySendMail
    - SaferMail 0.7
    - Smtp Auth Email Script
    - Search Mime Email Structure
    - PHP Text / HTML Email with Attachments 2.1
    - Simple way to send mail wih one attached Doc...
    - Generic POP3 Class
    - PHP Text / HTML Email with Unlimited Attachm...
    - Another SendMail
    - email with attachment
    - Get Email Addresses from Strings
    - EmailCode
    - Email Validation - Gone Wild

    Developer Shed Affiliates

     



    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap