Forum Moderators: coopster & phranque

Message Too Old, No Replies

Email address validation - perl

         

Learning Curve

2:40 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



(I couldn't find anything on this with the search function although I know I've read about on this forum somewhere.)

I would like to check the validity of an e-mail address on a form before the form is sent to me. I hate taking all the time to respond to someone just to find out they put in a bogus (or typo-ed) email address.

When I researched this once before I think there were several options / modules but I couldn't decide which was best.

I also remember thinking that I would have to get my host to load the module which would be a pain in the neck.

Am I making this harder than it needs to be?

Any recommendations on how to set this up?

Josk

11:29 am on Sep 17, 2003 (gmt 0)

10+ Year Member



Are you trying to determine if the email i syntatically correct, or whether the email is "real". The former can be done by a regex, but is a long one. Try doing a search on google... For the latter why not send an email to the email address with a link for the receiver to click on to validate the address. If the address is not validated then you know that the email address never got delivered.

sugarkane

11:56 am on Sep 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can check for syntax using this:

if ($email_address =~ /^(\w¦\-¦\_¦\.)+\@((\w¦\-¦\_)+\.)+[a-zA-Z]{2,}$/)
{
print "$email_address is valid";
}
else {
print "$email_address is invalid";
}

Unfortunately there's no way to check if an email address actually exists apart from sending an email to it... There's a part of the SMTP protocol that provides for asking a mailserver whether or not it'd accept mail for a particular address, but as this is an easy way for spammers to obtain 'live' addresses it's rarely enabled.

Storyteller

2:28 am on Sep 18, 2003 (gmt 0)

10+ Year Member



Email::Valid from CPAN does all that and can also check domain's actual existance.