note 87172 added to function.getmxrr
| From: | feha at vision dot to | Date: | Sat, 22 Nov 2008 14:29:04 +0000 |
| Subject: | note 87172 added to function.getmxrr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146829@lists.php.net to get a copy of this message | ||
On the example below if getmxrr does not exist it will try with fsockopen.
This way it works for windows without getmxrr ...
<?php
function validate_email($email)
{
//by Femi Hasani [www.vision.to]
if(!preg_match ("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $email))
return false;
list($prefix, $domain) = split("@",$email);
if(function_exists("getmxrr") && getmxrr($domain, $mxhosts))
{
return true;
}
elseif (@fsockopen($domain, 25, $errno, $errstr, 5))
{
return true;
}
else
{
return false;
}
}
?>
Usefull and simple solution ...
else it can be added fisrt to check os and function than create a widows version of getmxrr ....
<?php
if(!defined("OS"))
{
@php_uname();//detect server OS
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
define("OS","WIN");//define OS contsant
} else {
define("OS","Other");
}
}
if(!function_exists("getmxrr") && OS == "WIN")
{
function getmxrr ()
{
your windows version ...
}
}
?>
Hope this helps ...
----
Server IP: 212.63.193.10
Probable Submitter: 81.170.222.214
----
Manual Page -- http://www.php.net/manual/en/function.getmxrr.php
Edit -- https://master.php.net/note/edit/87172
Del: integrated -- https://master.php.net/note/delete/87172/integrated
Del: useless -- https://master.php.net/note/delete/87172/useless
Del: bad code -- https://master.php.net/note/delete/87172/bad+code
Del: spam -- https://master.php.net/note/delete/87172/spam
Del: non-english -- https://master.php.net/note/delete/87172/non-english
Del: in docs -- https://master.php.net/note/delete/87172/in+docs
Del: other reasons-- https://master.php.net/note/delete/87172
Reject -- https://master.php.net/note/reject/87172
Search -- https://master.php.net/manage/user-notes.php