function is_email($email){
$x = '\d\w!\#\$%&\'*+\-/=?\^_`{|}~'; //just for clarity
return count($email = explode('@', $email, 3)) == 2
&& strlen($email[0]) < 65
&& strlen($email[1]) < 256
&& preg_match("#^[$x]+(\.?([$x]+\.)*[$x]+)?$#", $email[0])
&& preg_match('#^(([a-z0-9]+-*)?[a-z0-9]+\.)+[a-z]{2,6}.?$#', $email[1]);
}