Torna indietro   Mr. Webmaster Forum > Fare Web > PHP

Rispondi
 
LinkBack Strumenti discussione Modalità visualizzazione
  #1 (permalink)  
Vecchio 02-10-2009, 22.20.38
Utente Registrato
 
Data registrazione: 02-10-2009
Messaggi: 2
Verificare esistenza indirizzo e-mail in php

Ho deciso di utilizzare questa classe, presa da phpclasses per verificare l'esistenza di indirizzi e-mail, ma ho incontrato qualche problemino:

Codice:
define ('DEBUG_OK', false); 
class CCheckMail 
{ 
var $timeout = 10; 
var $domain_rules = array ("aol.com", "bigfoot.com", "brain.net.pk", "breathemail.net", 
"compuserve.com", "dialnet.co.uk", "glocksoft.com", "home.com", 
"msn.com", "rocketmail.com", "uu.net", "yahoo.com", "yahoo.de"); 

function _is_valid_email ($email = "") 
{ return preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $email); } 

function _check_domain_rules ($domain = "") 
{ return in_array (strtolower ($domain), $this->domain_rules); } 

function execute ($email = "") 
{ 
if (!$this->_is_valid_email ($email)) 
{ return false; } 

$host = substr (strstr ($email, '@'), 1); 

if ($this->_check_domain_rules ($host)) 
{ return false; } 

$host .= "."; 

if (getmxrr ($host, $mxhosts[0], $mxhosts[1]) == true) 
{ array_multisort ($mxhosts[1], $mxhosts[0]); } 
else 
{ 
$mxhosts[0] = $host; 
$mxhosts[1] = 10; 
} 
if (DEBUG_OK) { print_r ($mxhosts); } 

$port = 25; 
$localhost = $_SERVER['HTTP_HOST']; 
$sender = 'info@' . $localhost; 

$result = false; 
$id = 0; 
while (!$result && $id < count ($mxhosts[0])) 
{ 
if (function_exists ("fsockopen")) 
{ 
if (DEBUG_OK) { print_r ($id . " " . $mxhosts[0][$id]); } 

if ($connection = fsockopen ($mxhosts[0][$id], $port, $errno, $error, $this->timeout)) 
{ 
fputs ($connection,"HELO $localhost\r\n"); 
$data = fgets ($connection,1024); 
$response = substr ($data,0,1); 

if (DEBUG_OK) { print_r ($data); } 

if ($response == '2')
{ 
fputs ($connection,"MAIL FROM:<$sender>\r\n"); 
$data = fgets($connection,1024); 
$response = substr ($data,0,1); 
if (DEBUG_OK) { print_r ($data); } 

if ($response == '2')
{ 
fputs ($connection,"RCPT TO:<$email>\r\n"); 
$data = fgets($connection,1024); 
$response = substr ($data,0,1); 
if (DEBUG_OK) { print_r ($data); } 

if ($response == '2')
{ 
fputs ($connection,"data\r\n"); 
$data = fgets($connection,1024); 
$response = substr ($data,0,1); 
if (DEBUG_OK) { print_r ($data); } 

if ($response == '2')
{ $result = true; } 
} 
} 
} 

fputs ($connection,"QUIT\r\n"); 
fclose ($connection); 
if ($result) { return true; } 
} 
} 
else 
{ break; } 
$id++; 
} 
return false; 
} 
}
Siccome nessuna mail risulta valida, ho provato a "stampare" alcune variabili. Stampando $data, il risultato è che non è supporato il metodo HELO. Qualcuno sarebbe in grado di aiutarmi?
Grazie mille a tutti.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Segnalo.Alice.it!OK Notizie!
Rispondi citando
Link sponsorizzati
  #2 (permalink)  
Vecchio 03-10-2009, 12.51.31
L'avatar di Eliox
Moderatore
 
Data registrazione: 25-02-2005
Messaggi: 2,351
usa quest'altra classe, è molto semplice e funziona bene
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Segnalo.Alice.it!OK Notizie!
Rispondi citando
  #3 (permalink)  
Vecchio 04-10-2009, 14.50.06
Utente Registrato
 
Data registrazione: 02-10-2009
Messaggi: 2
Io l'ho provata, ma la pagina ci mette troppo tempo a caricarsi, anzi io non sono ancora riuscito a vederne finito il caricamento. Potrebbe essere un ciclo che si ripete. A te funziona?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Segnalo.Alice.it!OK Notizie!
Rispondi citando
Rispondi

Tags
classe

Strumenti discussione
Modalità visualizzazione

Regole di scrittura
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Attivato
Le faccine sono Attivato
Il codice [IMG] è Attivato
Il codice HTML è Disattivato
Trackbacks are Attivato
Pingbacks are Attivato
Refbacks are Attivato



Tutti gli orari sono GMT +2. Adesso sono le 15.08.51.


Basato su: vBulletin versione 3.8.4 | ©2000 - 2010, Jelsoft Enterprises Ltd. | Search Engine Optimization by vBSEO 3.2.0
Mr. Webmaster NON è assolutamente responsabile per il contenuto dei messaggi inseriti dagli utenti.