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 $code = Mail::VRFY::CheckAddress($emailaddress);

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

  my $english = Mail::VRFY::English($code);

        

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 conversation, to ensure the mailserver does not give a 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). this is a per-operation timeout, meaning there is a separate timeout on a DNS query, and each smtp conversation.

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.

This module provides an English sub that will convert the code to English for you.

EXAMPLES

  use Mail::VRFY;
  my $email = shift;
  unless(defined($email)){
    print "email address to be tested: ";
    chop($email=<STDIN>);
  }
  my $code = Mail::VRFY::CheckAddress($email);
  my $english = Mail::VRFY::English($code);
  if($code){
    print "Invalid email address: $english  (code: $code)\n";
  }else{
    print "$english\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 valid, and others will set up a queing mechanism to try again later.

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

Jeremy Kister : http://jeremy.kister.net./