|
|
|
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");
?> | | |
|
| email validator check checker email e-mail email address Categories : PHP, Email, Regexps | | | validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email
addresses via SMTP and regex. Categories : Email, Regexps, PHP | | | making links from text Categories : PHP, Regexps, Email | | | Clever Email Validation Function - E-Mail validation function with an eregi expression and socket connection. Categories : Email, PHP, Regexps | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | email new items in db Categories : PHP, Email, Databases, MySQL, Beginner Guides | | | This script is a contact form between users of a
website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps | | | Simple way to replace a variable value in a .conf (.ini) file using a
webbrowser - the first stage of a complete universal configuration editor Categories : PHP, Regexps, Code Editors, Filesystem | | | ereg -- Regular expression match Categories : PHP, PHP Functions, Regexps | | | Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip Categories : Email, Network, PHP, PHP Classes | | | Gets the browser and OS from the $_SERVER['http_user_agent'] variable in PHP Categories : PHP, HTTP, Regexps | | | a PHP Function to Get only the filename (remove the extension) using regular expressions. Categories : PHP, Regexps, Beginner Guides | | | PHP Script to find url links in a page Categories : PHP, URLs, Regexps, Arrays | | | A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more. Categories : Email, PHP, LDAP | | | Encoding data using PGP via PHP's proc_* functions Categories : Cryptography, Security, Email, PHP, PGP | |
| | | | 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.
| |
|
|
|