Item Description: Checks the validity of an email address (hence the name ;-)
Review Synopsis:
Email::Valid
Description
Checks an email address for rfc822 compliance, and, optionally, can also perform an mx check on the domain.
It's worth pointing out here again that attempting to check an email address with a regexp is a very bad idea (see merlyn's reaction to one such attempt, or the explanation of it from perlfaq 9).
Requirements
- Mail::Address
- Net::DNS (if you wish to do mx checks)
Who Should Use It?
- Anyone who wants a simple and fairly reliable check of an email address submitted via a form over the web.
Any Bad Points?
- Not a 100% reliable method of verifying an email address (can't be done, except by sending mail to it).
- Requests can sometimes take a while to process.
Example
#!/usr/bin/perl require 5; use strict; use Email::Valid; use vars qw($addr $email); if (@ARGV) { foreach $email (@ARGV) { eval { unless ($addr = Email::Valid->address( -address => $email, -mxcheck => 1 )) { warn "address failed $Email::Valid::Details check."; } }; warn "an error was encountered: $@" if $@; } } else { print <<EOF; Usage: $0 [email(s)] Synopsis: checks email address is rfc822 compliant, and performs an mx + check on the domain. EOF }
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Email::Valid
by KM (Priest) on Sep 13, 2000 at 19:12 UTC | |
by kilinrax (Deacon) on Sep 13, 2000 at 19:29 UTC | |
by KM (Priest) on Sep 19, 2000 at 06:37 UTC | |
by turnstep (Parson) on Sep 15, 2000 at 00:58 UTC | |
by Anonymous Monk on Jul 16, 2001 at 11:29 UTC | |
by Aristotle (Chancellor) on May 23, 2002 at 09:58 UTC |