Średnio 7x w tygodniu się o to pytają, więc można z łatwością poszukać...
<?php
function verifyEmail($email) {
$wholeexp = '/^(.+?)@(([a-z0-9.-]+?).[a-z]{2,5})$/i';
$userexp = "/^[a-z0-9~!#$%&()-_+=[];:'",./]+$/i";
if (preg_match($wholeexp, $email, $regs)) {
$username = $regs[1];
$host = $regs[2];
if (checkdnsrr($host, MX)) {
if (preg_match($userexp, $username)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
?>
<?php
function checkMail($email) {
return preg_match('/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/', $email); }
if (checkMail('user@host.pl'))
echo 'Adres e-mail jest poprawny.'; else echo 'Niepoprawny format adresu e-mail.'; ?>
<?php
function PoprawnyEmail($adres)
{
return (preg_match ("/(@.*@)|(..)|(@.)|(.@)|(^.)/", $adres) || preg_match("/^.+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$/",$adres))); }
?>