Mail::VRFY - Utility to verify an email address
use Mail::VRFY;
my $result = Mail::VRFY::CheckAddress($emailaddress);
my $result = Mail::VRFY::CheckAddress(addr => $emailaddress, method => 'extended', debug => 0);
Mail::VRFY was derived from Pete Fritchman's Mail::Verify. Lots of code has been plucked. This package attempts to be completely compatibile with Mail::Verify.
Mail::VRFY
Mail::VRFY provides a CheckAddress function for verifying email addresses. Lots can be checked, according to the method option, as described below.
CheckAddress
method
Mail::VRFY differs from Mail::Verify in that:
A. More granular control over what kind of checks to run (via the method option).
B. Email address syntax checking is much more stringent.
C. After making a socket to an authoritative SMTP server, we can start a SMTP converstation, to ensure the mailserver does not give a permanent failure on RCPT TO.
D. More return codes.
If ADDR is not given, then it may instead be passed as the addr option described below.
ADDR
addr
OPTIONS are passed in a hash like fashion, using key and value pairs. Possible options are:
OPTIONS
addr - The email address to check
method - Which method of checking should be used:
syntax - check syntax of email address only (no network testing). compat - check syntax, DNS, and MX connectivity (i.e. Mail::Verify) extended - compat + talk SMTP to see if server will reject RCPT TO
debug - Print debugging info to STDERR (0=Off, 1=On).
Here are a list of return codes and what they mean:
use Mail::VRFY; my $email = shift; unless(defined($email)){ print "email address to be tested: "; chop($email=<STDIN>); } my $result = Mail::VRFY::CheckAddress($email); if($result){ print "Invalid email address: ${result}\n"; }else{ print "$email seems to be valid\n"; }
An SMTP server can reject RCPT TO at SMTP time, or it can accept all recipients, and send bounces later. All other things being equal, Mail::VRFY will not detect the invalid email address in the latter case.
Greylisters will cause you pain; look out for return code 7. Some users will want to deem email addresses returning code 7 are invalid, others will want to assume they are valid.
Email address syntax checking does not conform to RFC2822, however, it will work fine on email addresses as we usually think of them. (do you really want:
"Foo, Bar" <test((foo) b`ar baz)@example(hi there!).com>
be be considered valid ?)
Jeremy Kister - http://jeremy.kister.net/
3 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
'=item' outside of any '=over'
To install Mail::VRFY, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::VRFY
CPAN shell
perl -MCPAN -e shell install Mail::VRFY
For more information on module installation, please visit the detailed CPAN module installation guide.