1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| function mailCheck($Email)
{
// L'adresse email doit être correctement formattée
/*if(!eregi("^[[:alpha:]]{1}[[:alnum:]]*((\.|_|-)[[:alnum:]]+)*@[[:alpha:]]{1}[[:alnum:]]*((\.|-)[[:alnum:]]+)*(\.[[:alpha:]]{2,})$", $Email))
exit('L\'adresse '.$Email.' est mal formatée');*/
// On récupère le domaine
list(,$domain ) = split('@',$Email);
// On cherche des enregistrements MX dans les DNS
if (getmxrr($domain, $MXHost))
$ConnectAddress = $MXHost[0];
else
$ConnectAddress = $domain;
// On créé la connexion sur le port smtp (25)
$Connect = @fsockopen($ConnectAddress,25,&$errno,&$errstr);
if($Connect)
{
if(ereg("^220", $Out = fgets($Connect, 1024)))
{
fputs ($Connect, "HELO {$_SERVER['HTTP_HOST']}\r\n");
$Out = fgets ( $Connect, 1024 );
fputs ($Connect, "MAIL FROM: <{$Email}>\r\n");
$From = fgets ( $Connect, 1024 );
fputs ($Connect, "RCPT TO: <{$Email}>\r\n");
$To = fgets ($Connect, 1024);
fputs ($Connect, "QUIT\r\n");
fclose($Connect); |
Partager