WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : E-mail address check
Categories : PHP, Email, Regexps Click here to Update Your Picture
Olaf Lederer
Date : May 25th 2005
Grade : 2 of 5 (graded 5 times)
Viewed : 14675
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Olaf Lederer
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

This simple function validates an e-mail address first by checking against a regular expression and second that the mail host exists. The DNS check fails if there is no MX record for the tested e-mail address. This function is an optimum validation for contact forms, CMS and member systems. Don't forget that the function "checkdnsrr" will not work on windows servers.

<?php
function check_email($mail_address) {
   
$pattern = "/^[\w-]+(\.[\w-]+)*@";
   
$pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i";
    if (
preg_match($pattern, $mail_address)) {
       
$parts = explode("@", $mail_address);
        if (
checkdnsrr($parts[1], "MX")){
            echo
"The e-mail address is valid.";
           
// return true;
       
} else {
            echo
"The e-mail host is not valid.";
           
// return false;
       
}
    } else {
        echo
"The e-mail address contains invalid charcters.";
       
// return false;
   
}
}
check_email("INFO@google.co.uk");
?>



making links from text
Categories : PHP, Regexps, Email
EAvalidator - This class can be used to validate an e-mail address by checking its domain.
Categories : PHP, PHP Classes, Email, Regexps
Clever Email Validation Function - E-Mail validation function with an eregi expression and socket connection.
Categories : Email, PHP, Regexps
validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email addresses via SMTP and regex.
Categories : Email, Regexps, PHP
email validator check checker email e-mail email address
Categories : PHP, Email, Regexps
how to check if a string contains a letter from a different language?
Categories : PHP, Regexps, Languages
Show Source with Line Numbers
Categories : PHP, Regexps, Filesystem
PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
Three Cool Classes and One Trick
Categories : PHP, PHP Classes, Graphics, Email
What is the best way to split a string that consists of two bits of data seperated by whitespace?
Categories : Regexps, Strings, PHP
Email a user with out exposing email address
Categories : PHP, Databases, MySQL, Email
Parse html (title :: meta)
Categories : PHP, HTML and PHP, Regexps
Sample WML Mailer
Categories : PHP, WAP, WML, Email
Formit 1.0. PHP Very easy to implement form-template(s) to email script. Works with multiple templates and HTML-format email. Only one file!
Categories : PHP, Email, HTML
Sending email with random details
Categories : PHP, Email, Debugging
 Indiana Jones wrote :1748
This Script is not RFC 2822 Valid.
Emails like:

jeff^lobster@domain.com
jeff’lobster@domain.com
jeff’lobster{yummy}@domain.com

are valid RFC 2822 email adresses but will be flaged as incorrect by this script.