The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mail::VRFY - Utility to verify an email address

SYNOPSIS

use Mail::VRFY;

my $result = Mail::VRFY::CheckAddress($emailaddress);

my $result = Mail::VRFY::CheckAddress(addr => $emailaddress, method => 'extended', timeout => 12, debug => 0);

DESCRIPTION

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 provides a CheckAddress function for verifying email addresses. Lots can be checked, according to the method option, as described below.

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.

CONSTRUCTOR

CheckAddress( [ADDR] [,OPTIONS] );

If ADDR is not given, then it may instead be passed as the addr option described below.

OPTIONS are passed in a hash like fashion, using key and value pairs. Possible options are:

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

timeout - Number of seconds to wait for data from remote host (Default: 12).

debug - Print debugging info to STDERR (0=Off, 1=On).

RETURN VALUE

Here are a list of return codes and what they mean:

0 The email address appears to be valid.
1 No email address was supplied.
2 There is a syntactical error in the email address.
3 There are no MX or A DNS records for the host in question.
4 There are no SMTP servers accepting connections.
5 All SMTP servers are misbehaving and wont accept mail.
6 All the SMTP servers temporarily refused mail.
7 One SMTP server permanently refused mail to this address.

EXAMPLES

  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";
  }

CAVEATS

A 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 6. Some users will want to deem email addresses returning code 6 invalid, others will want to assume they are valid.

RESTRICTIONS

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>

to be considered valid ?)

AUTHOR

<a href="http://jeremy.kister.net./">Jeremy Kister</a>

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 72:

You forgot a '=back' before '=head1'

Around line 76:

'=item' outside of any '=over'

Around line 92:

You forgot a '=back' before '=head1'