Search Perl pages
Professions, Sciences, Humanities, Business, ...
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...
Conversions, tests, processing, manipulation,...
Integer, Floating point, Matrix, Statistics, Boolean, ...
Algorithms, Memory, Process control, Debugging, ...
Data storage, Integrity, Encryption, Compression, ...
Networks, protocols, Interprocess, Remote, Client Server, ...
Timing, Calendar and Clock, Audio, Video, Printer, Controls...
Management, Filtering, File & Directory access, Viewers, ...
Next: How do I decode a MIME/BASE64 string?
Without sending mail to the address and seeing whether it bounces (and even then you face the halting problem), you cannot determine whether an email address is valid. Even if you apply the email 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 email
addresses with a simple regexp, such as
/^[\w.-]+\@([\w.-]\.)+\w+$/. 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 email to (say, Bill Clinton or your postmaster), and then makes sure that the hostname given can be looked up in
DNS. It's not fast, but it works.
Here's an alternative strategy used by many
CGI script authors: Check the email address with a
simple regexp (such as the one above). If the regexp matched the address,
accept the address. If the regexp didn't match the address, request
confirmation from the user that the email address they entered was correct.
Source: Perl FAQ: Networking
Copyright: Copyright (c) 1997 Tom Christiansen and Nathan Torkington.
Previous: How do I decode a CGI form?
(Corrections, notes, and links courtesy of RocketAware.com)
Up to: Email Processing
Search | About | Comments | Submit Path: RocketAware > Perl >
RocketAware.com is a service of Mib Software
Copyright 2000, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments