CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: Throw Down The Gauntlet:
email validation

 



julian51
stranger

Apr 12, 2001, 7:16 AM

Post #1 of 3 (11148 views)
email validation Can't Post

I am looking for a script which actually checks to see if an email address exist before sending mail to the address. if anyone knows of such a script, please post the link to it.
thanks,
julian



etheracide
journeyman

Jul 5, 2001, 9:24 AM

Post #2 of 3 (11106 views)
Re: email validation [In reply to] Can't Post

I will see what I can find. It is rather easy to configure any script to check for valid format to ensure that the person atleast enters a properly formatted address. But for it to check if it is an actual, existing address...that could take some major work. Of course if someone signs with an address that isn't their's and they believe is made up, it could be an actual address of someone else and they would still receive the mail. And it wouldn't be checking for accounts that may be on hold or 'locked down' due to the person not checking their mail enough..in which case, the address does exist, but the mail would be bounced back. I will see what I can find however.



Jasmine
Administrator

Jul 5, 2001, 10:05 AM

Post #3 of 3 (11104 views)
Re: email validation [In reply to] Can't Post

Email checking can be included in any program quite easily.


Code
use Email::Valid; 
print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no');

More on Email::Valid

From the Perl FAQ - How do I check a valid mail address?:

You can't, at least, not in real time. Bummer, eh?

Without sending mail to the address and seeing whether there's a human on the other hand to answer you, you cannot determine whether a mail address is valid. Even if you apply the mail header standard, you can have problems, because there are deliverable addresses that aren't RFC-822 (the mail header standard) compliant, and addresses that aren't deliverable which are compliant.

Many are tempted to try to eliminate many frequently-invalid mail addresses with a simple regex, such as /^[\w.-]+\@([\w.-]\.)+\w+$/. It's a very bad idea. However, this also throws out many valid ones, and says nothing about potential deliverability, so is not suggested. Instead, see http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/ckaddr.gz , which actually checks against the full RFC spec (except for nested comments), looks for addresses you may not wish to accept mail to (say, Bill Clinton or your postmaster), and then makes sure that the hostname given can be looked up in the DNS MX records. It's not fast, but it works for what it tries to do.

Our best advice for verifying a person's mail address is to have them enter their address twice, just as you normally do to change a password. This usually weeds out typos. If both versions match, send mail to that address with a personal message that looks somewhat like:


Code
    Dear someuser@host.com, 
Please confirm the mail address you gave us Wed May 6 09:38:41
MDT 1998 by replying to this message. Include the string
"Rumpelstiltskin" in that reply, but spelled in reverse; that is,
start with "Nik...". Once this is done, your confirmed address will
be entered into our records.

If you get the message back and they've followed your directions, you can be reasonably assured that it's real.

A related strategy that's less open to forgery is to give them a PIN (personal ID number). Record the address and PIN (best that it be a random one) for later processing. In the mail you send, ask them to include the PIN in their reply. But if it bounces, or the message is included via a ``vacation'' script, it'll be there anyway. So it's best to ask them to mail back a slight alteration of the PIN, such as with the characters reversed, one added or subtracted to each digit, etc.



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives