PHP ile email dogrulama

This script will not only check the email by regex but it will also use mx records to check if the domain exists. It also checks against one of the most popular recieve only free email sites.


[code]
function VALIDATE_EMAIL ( $email ) {
global $mxrecords;

if ( $email == '' ) return '';
list ( $username , $domaintld ) = split ( "@" , $email , 2 ) ;

$domaintld = strtolower ( $domaintld ) ;

if ( $domainltd == 'dodgeit.com' ) return false;

if ( !getmxrr ( $domaintld , $mxrecords ) || !preg_match ( "(^[-\w\.]+$)" , $username ) ) return false;

return true;

}[/code]



[code]
if (VALIDATE_EMAIL('test@gmail.com')) {
// valid
} else {
// invalid
}[/code]

Konular

Hanci.org sizlere daha iyi hizmet sunmak için çerezleri kullanıyor.
Hanci.org sitesini kullanarak çerez politikamızı kabul etmiş olacaksınız.
Detaylı bilgi almak için Gizlilik ve Çerez Politikası metnimizi inceleyebilirsiniz.