]>
git.defcon.no Git - hermes/blob - lib/check_email.php
3 function check_email_address($email) {
4 // First, we check that there's one @ symbol,
5 // and that the lengths are right.
6 if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
7 // Email invalid because wrong number of characters
8 // in one section or wrong number of @ symbols.
11 // Split it into sections to make life easier
12 $email_array = explode("@", $email);
13 $local_array = explode(".", $email_array[0]);
14 for ($i = 0; $i < sizeof($local_array); $i++
) {
16 (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
21 // Check if domain is IP. If not,
22 // it should be valid domain name
23 if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
24 $domain_array = explode(".", $email_array[1]);
25 if (sizeof($domain_array) < 2) {
26 return false; // Not enough parts to domain
28 for ($i = 0; $i < sizeof($domain_array); $i++
) {
30 (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$",