http://qs321.pair.com?node_id=31747

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

Who Should Use It?

Any Bad Points?

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 }