Lost Password?


  #1 (permalink)  
Old 08-10-2006, 09:52 PM
Jordan's Avatar   
Jordan Jordan is online now
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,666
Last Blog:
PHP Objects, Patterns,...
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default PHP: Validate Email Address

This function actually validates an email address against an MX record. I found this somewhere and modified it slightly.

Name: validateemail.php
Description: Validates an email against MX records

Usage:
include validateemail.php
Pass an email to validateEmail();
Example:

PHP Code:
 if (validateEmail("somename@domain.com")) {
//code block

Attached Files To view attachments in this forum your post count must be 1 or greater. You currently have 0 posts.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!

Last edited by John; 05-30-2007 at 04:45 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-02-2006, 03:18 PM
skilletsteve skilletsteve is offline
Learning Programmer
 
Join Date: Aug 2006
Posts: 45
Rep Power: 9
skilletsteve is on a distinguished road
Default

what exactly are MX records?
do you need to have your own set of MX records for it to check against?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-04-2006, 10:50 AM
Jordan's Avatar   
Jordan Jordan is online now
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,666
Last Blog:
PHP Objects, Patterns,...
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

MX records are records added in the DNS file. MX records are for email inside of the DNS system. The script I provided above will actually check to see if the mail/domain exists.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-11-2007, 06:38 AM
moguai moguai is offline
Newbie
 
Join Date: Feb 2007
Posts: 1
Rep Power: 0
moguai is on a distinguished road
Default

This looks great, thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-30-2007, 03:28 AM
lambert1969 lambert1969 is offline
Newbie
 
Join Date: May 2007
Posts: 1
Rep Power: 0
lambert1969 is on a distinguished road
Default

Looks great!, thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 06-23-2007, 10:30 AM
yosutanto yosutanto is offline
Newbie
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0
yosutanto is on a distinguished road
Default

Thanks a lot! will try it now.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-12-2007, 12:17 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,478
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Im working on a whole validation class, here is my Email Validation

PHP Code:
     /**
     *@param $Email is the email address you wish to validate
     *@return $result[0] will either be true or false. True
     *    meaning the email is valid - False meaning the email
     *    meaning the email is invalid.
     *@return $result[1] is a brief message explaining the result.
     */
    
function VerifyEmail ($Email)
    {

        
$result = array();

        
#Use a regular expression to make sure the $Email string is in proper format
        #<username>@<domain>.<suffix> || <username>@<subnet>.<domain>.<suffix> 
        
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$Email)) {
            
$result[0] = false;
            
$result[1] = "$email is not properly formatted.";
            return 
$result;
        } 


        list (
$Username$Domain) = split ("@"$Email);

        
#Verify the MX record.
        
if (getmxrr($Domain$MXHost)) {
            
$result[0] = true;
            
$result[1] = "$email appears to be valid.";
            return 
$result;
        } else {
            
#Establish a connection to the server.
            
if (@fsockopen($Domain25$errno$errstr30)) {
                
$result[0] = true;
                
$result[1] = "$email appears to be valid.";
                return 
$result;
            } else  {
                
$result[0] = false;
                
$result[1] = "Cannot connect to the server.";
                return 
$result;
            }
        }
    } 
//End VerifyEmail 
Usage:
PHP Code:
    $result =  VerifyEmail ($Email);
    if(
$result[0]) {
        
//email is valid
    

__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-12-2007, 02:03 AM
sh44n sh44n is offline
Newbie
 
Join Date: Aug 2007
Posts: 1
Rep Power: 0
sh44n is on a distinguished road
Default

Nice one
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 09-02-2007, 12:34 PM
tmarsha4 tmarsha4 is offline
Newbie
 
Join Date: May 2007
Posts: 1
Rep Power: 0
tmarsha4 is on a distinguished road
Default

very cool, ill be using this for sure. thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 09-05-2007, 03:02 PM
matthewk matthewk is offline
Newbie
 
Join Date: Sep 2007
Posts: 2
Rep Power: 0
matthewk is on a distinguished road
Default

Thanks, wanting to check it out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP:Tutorial - Email Verification John PHP Tutorials 3 09-19-2007 01:19 PM
PHP 4 end of life announcement Jordan Programming News 4 08-30-2007 10:55 AM
Validating an email address kromagnon PHP Forum 2 07-30-2006 11:24 AM


All times are GMT -5. The time now is 08:41 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads