note 48673 added to function.getmxrr
| From: | siclawrence at gmail dot com | Date: | Tue, 04 Jan 2005 14:43:33 +0000 |
| Subject: | note 48673 added to function.getmxrr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82696@lists.php.net to get a copy of this message | ||
This code replicates online tools that let you check if an email address is valid. First it checks
if the email format is correct, then looks up and prints the mx records. All nicely formatted with
fancy words that in the end prints whether the email address valid or invalid.
<?php
$email = "email@domain.com";
print("Checking: $email<br>");
if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$", $email)) {
print("Format Test: PASSED<br>");
print("Online host verification Test...<br><br>");
print("MX Records for: $email<br>");
list($alias, $domain) = split("@", $email);
if (checkdnsrr($domain, "MX")) {
getmxrr($domain, $mxhosts);
foreach($mxhosts as $mxKey => $mxValue){
print(" $mxValue<br>");
}
print("Online host verification Test: PASSED<br><br>");
print("Email Status: VALID");
} else {
print(" No records found.<br>");
print("Online host verification Test: FAILED<br><br>");
print("Email Status: INVALID");
}
} else {
print("Format Test: FAILED<br><br>");
print("Invalid email address provided.<br><br>");
print("Email Status: INVALID");
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.getmxrr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48673
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48673&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48673&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48673&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48673&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48673&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48673&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48673&report=yes
Search -- http://master.php.net/manage/user-notes.php