From: Devrim GUNDUZ (devrim@gunduz.org)
Date: Fri 15 Jul 2005 - 02:21:37 EEST
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Merhaba,
On Tue, 12 Jul 2005, bunyamin wrote:
> bir e-mail adersinin gercek olup olmadigini anlayan bi fonksiyona
> ihtiyacım var...
>
> boyle bi kod varmi??
>
> kisi e-mail adresini yazınca boyle bir e-mail adresi gercekten varmi
> yokmu kontrol etmeli...
Bu biraz zor; ama en azından alan adını vs kontrol eden birşey ararsanız
şunu kullanabilirsiniz. Bunu PostgreSQL.org'da kullanıyoruz biz:
=============================================
function verify_email($Address)
{
/* Check the email address structure
// Returns 0 if the email is correctly structured and has a valid MX record
// Returns 1 if incorrectly structured (i.e. invalid and could never work)
Returns 2 if it seems alright but there is no valid dns entry
*/
if (eregi("^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}\$", $Address) == 0)
{
return 1;
}
// Get the user/domain
$User = strtok($Address,"@");
$Domain = strtok("") . ".";
$ // Check for the domain MX records
if (getmxrr($Domain, $Servers)) {
return 0;
}
$ // No MX record, so maybe it's a host
if (gethostbyname($Domain) == $Domain) {
return 2;
} else {
return 0;
}
}
=======================================================
Bunu da şu şekilde kullanacaksınız:
$emailret = verify_email(rawurldecode($e_posta_adresi));
if ($emailret != 0)
{
// E-posta adresi gecersiz
...
exit();
}
Saygılar,
- --
Devrim GUNDUZ
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.tdmsoft.com.tr http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFC1vODtl86P3SPfQ4RAonyAKCMTfJOLoLq8gtIJItaLvrOttqzTgCgosW/
SL9KN2mRktMAyLIaKCpPNgE=
=K2Jj
-----END PGP SIGNATURE-----
_______________________________________________
Linux-programlama mailing list
Linux-programlama@liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux-programlama