Email validation

jgauthier

New Member
I need to validate email addresses.
How can I accomplish this? Using a regex would be nice, but I don't know of any support for progress and regex.

Suggestions?
 
You say you need to validate an e-mail address, to what contex do you wish to validate?
The obvious and simplest validation is the format.
Analyse the string that is the e-mail address, for correct format.
Does it follow the format of <username> @ <domain>, that is fairly simple to do.
The hardest part is to actually check the string given, once satisfied that the string given is an address in the correct format, start a different process / procedure to PING the address string given. If returned error then obviousley NOT a valid email.
 
Thanks.

I wrote a perl script and used input through to call it.

-=-=-=
my($addr) = $ARGV[0];
my($domain, $valid);

if ($addr =~ /^[^@]+@([-\w]+\.)+[A-Za-z]{2,4}$/) {
$domain = (split(/@/, $addr))[1];
$valid = 0;
open(DNS, "nslookup -q=any $domain |") ||
return(-1);
while (<DNS>) {
$valid = 1 if (/^$domain.*\s(mail exchanger|internet address)\s=/);
}
if ($valid == 1) {
printf ("Valid");
} else {
printf "Bad email domain: ";
}
} else {
printf "Bad email: ";
}
 
Back
Top