http://www.email-unlimited.com/tools/verify-email.aspx
Qualcuno sa come fa questo a verificare se esiste il dominio e l'username?
Rifarlo in PHP?
http://www.email-unlimited.com/tools/verify-email.aspx
Qualcuno sa come fa questo a verificare se esiste il dominio e l'username?
Rifarlo in PHP?
questo è per il dominio, non ho mai provato a verificare la user (son un po nubbo) ma avevo letto che un metodo era provare a inviare una richiesta al server mail in bkground e vedere l'esito...ma sicuramente altri ti sapranno aiutare meglio di me o almeno darti delle info più corretteCodice PHP:
//valida la mail
$validemail= "^[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$%&_-])*".
"@[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$%&_-])*$";
if (!empty($email) && !eregi($validemail, $email))
{$errors["email"] = "- email assente,non corretta";
}
elseif (strlen($email) > 30)
{$errore["email"] = "- la mail non puo essere piu lunga di 30 caratteri
";}
elseif (function_exists("getmxrr") && function_exists("gethostbyname"))
{//estrae il dominio
$dominiomail= substr(strstr($email, '@'),1);
if (!(getmxrr($dominiomail, $temp) || gethostbyname($dominiomail) != $dominiomail))
{$errors["email"] = "- il dominio non esiste
";}
else
//controlla se nel db esiste già la mail
{$result=mysql_query("SELECT mail FROM user_per WHERE mail = '$email' ");
$rowmail=mysql_fetch_Array($result);
if (!empty($rowmail[0]))
{$errors["email"]= "- sei gia registrato con questa mail
";}
}
Intanto grazie mille, mi studio quello che hai postato.
lo hai trovato da qualche parte?
su in sitarello per un amico che ho fatto io, tutto per uso familiare quindi non so quanto sia "valido" scritto così a livello di sicurezza o altro.
comuqneu basta che cerchi le funzioni
gethostbyname()
getmxrr()
poi nel mio caso la mail è memorizzata in un db dove siamo registrati con user e pass e nel caso sia già esistente da esito negativo.
![]()
per l'account utente la tecnica dovrebbe essere quella di collegarsi direttamente al server smtp del dominio di cui fa parte l'utente (se ho user@domain.com mi collego al server MX di domain.com). Questo però presuppone di maneggiare i socket. In pratica devi simulare l'invio di una email:
HELO host
MAIL FROM:<mittente@dommittente.com>
RCPT TO:<user@domain.com>
QUIT
in base alla risposta al RCPT ho indicazioni sull'esistenza dell'account. Se il codice restituito è il 250 il recipient è accettato e quindi l'user esiste. Se il codice è diverso la casella non esiste. host in HELO dovrebbe essere il nome del sistema che si collega.
Caveat:
1) molti SMTP server non accettano connessioni da server che non siano essi stessi server smtp. Questo per evitare abusi.
2) con alcuni server il trucco non funziona. Questi restituiranno sempre un mittente esistente salvo poi non inviare l'email.
Questi sono solo alcuni suggerimenti per sperimantare.
Leggi il REGOLAMENTO!
E' molto complicato, un mucchio di input e output, una quantità di informazioni, un mucchio di elementi da considerare, ho una quantità di elementi da tener presente...
Drugo
http://www.sastgroup.com/leggi-tutor...tramite%20smtpCodice PHP:
<?php
class verificatore{
function verifica($host,$user){
$fp = fsockopen ($host, 25);
set_socket_blocking ($fp, true);
fputs ($fp, "Helo\n");
fgets ($fp, 2000);
fgets ($fp, 2000);
fputs ($fp, "Mail From:<$user@$host> \n");
fgets ($fp, 2000);
fputs ($fp, "RCPT to:aetos<$user@$host> \n");
$result= fgets ($fp, 2000);
$st= substr($result,0,3);
if ($st==250){
echo"Indirizzo email valido";
}
else
echo"Indirizzo email valido non valido";
}
}
//utilizziamo la classe tramite
$m=new verificatore;
$m->verifica("gmail.com","ilbonzo.org");
//dove [email]pippo@supereva.it[/email] e' l'indirizzo da validare
?>
Ho trovato questo, ma non mi sembra che funzioni, non mi valida alcuni indirizzi da me usati.
Suggerimenti?
1) quella classe utilizza il metodo che ho descritto precedentemente ma non mi sembra una implementazione impeccabile... in particolare bisognerebbe verificare che ogni richiesta fatta al server non ritorni errore. Alcuni server inoltre richiedono obbligatoriamente l'host come argomento di helo. Ma non credo sia questo a darti dei problemi.
2) il tuo problema è sicuramente il fatto che il parametro $host passato come argomento al metodo verifica non è il dominio ma il server MX. Non puoi inserire google.com ma il nome di un server smtp di google. Per Google ad esempio puoi usare: gsmtp163.google.com
In alternativa (cosa migliore) modifichi la classe facendo fare automaticamente la query dns per il record MX. Puoi usare getmxrr() . Il sockopen ovviamente lo farai sul server trovato.
In questo modo puoi inserire il dominio come argomento e il server smtp verrà automaticamente risolto.
Leggi il REGOLAMENTO!
E' molto complicato, un mucchio di input e output, una quantità di informazioni, un mucchio di elementi da considerare, ho una quantità di elementi da tener presente...
Drugo
Su php.net ho trovato questo.Codice PHP:
This script validates an e-mail adress using getmxrr and fsockopen
1. it validates the syntax of the address.
2. get MX records by hostname
3. connect mail server and verify mailbox(using smtp command RCTP TO:<email>)
When the function "validate_email([email])" fails connecting the mail server with the highest priority in the MX record it will continue with the second mail server and so on..
The function "validate_email([email])" returns 0 when it failes one the 3 steps above, it will return 1 otherwise
Grtz Lennart Poot
<?
function validate_email($email){
$mailparts=explode("@",$email);
$hostname = $mailparts[1];
// validate email address syntax
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
$b_valid_syntax=eregi($exp, $email);
// get mx addresses by getmxrr
$b_mx_avail=getmxrr( $hostname, $mx_records, $mx_weight );
$b_server_found=0;
if($b_valid_syntax && $b_mx_avail){
// copy mx records and weight into array $mxs
$mxs=array();
for($i=0;$i<count($mx_records);$i++){
$mxs[$mx_weight[$i]]=$mx_records[$i];
}
// sort array mxs to get servers with highest prio
ksort ($mxs, SORT_NUMERIC );
reset ($mxs);
while (list ($mx_weight, $mx_host) = each ($mxs) ) {
if($b_server_found == 0){
//try connection on port 25
$fp = @fsockopen($mx_host,25, $errno, $errstr, 2);
if($fp){
$ms_resp="";
// say HELO to mailserver
$ms_resp.=send_command($fp, "HELO microsoft.com");
// initialize sending mail
$ms_resp.=send_command($fp, "MAIL FROM:<support@microsoft.com>");
// try receipent address, will return 250 when ok..
$rcpt_text=send_command($fp, "RCPT TO:<".$email.">");
$ms_resp.=$rcpt_text;
if(substr( $rcpt_text, 0, 3) == "250")
$b_server_found=1;
// quit mail server connection
$ms_resp.=send_command($fp, "QUIT");
fclose($fp);
}
}
}
}
return $b_server_found;
}
function send_command($fp, $out){
fwrite($fp, $out . "\r\n");
return get_data($fp);
}
function get_data($fp){
$s="";
stream_set_timeout($fp, 2);
for($i=0;$i<2;$i++)
$s.=fgets($fp, 1024);
return $s;
}
// support windows platforms
if (!function_exists ('getmxrr') ) {
function getmxrr($hostname, &$mxhosts, &$mxweight) {
if (!is_array ($mxhosts) ) {
$mxhosts = array ();
}
if (!empty ($hostname) ) {
$output = "";
@exec ("nslookup.exe -type=MX $hostname.", $output);
$imx=-1;
foreach ($output as $line) {
$imx++;
$parts = "";
if (preg_match ("/^$hostname\tMX preference = ([0-9]+), mail exchanger = (.*)$/", $line, $parts) ) {
$mxweight[$imx] = $parts[1];
$mxhosts[$imx] = $parts[2];
}
}
return ($imx!=-1);
}
return false;
}
}
?>
Mi sembra funzioni, che ne dite?