NAME
Mail::CheckUser - checking email addresses for validness
SYNOPSIS
use Mail::CheckUser qw(check_email);
my $res = check_email($email_addr);
use Mail::CheckUser;
my $res = Mail::CheckUser::check_email($email_addr);
DESCRIPTION
This Perl module provides routines for checking validness of email address.
It makes several checks:
it checks syntax of email address;
it checks if there any MX record or at least A record for domain in email address;
it tries to connect to email server directly via SMTP to check if mailbox is valid. Old versions of this module have performed this check via VRFY command. Now module uses another check: it uses combination of commands MAIL and RCPT which simulates fake sending of email. It can detect bas mailboxes in many cases. For example hotmail.com mailboxes can be verified with MAIL/RCPT check.
If is possible to turn of all networking checks (second and third checks). See "GLOBAL VARIABLES".
This module was designed with CGIs (or any other dynamic Web content programmed with Perl) in mind. Usually it is required to check fast e-mail address in form. If check can't be finished in reasonable time e-mail address should be treated as valid. This is default policy. By default if timeout happens result of check is treated as positive (it can be overridden - see "GLOBAL VARIABLES").
IMPORTANT WARNING
In many cases there is no way to detect validness of email address with network checks. For example Postfix SMTP mail server (at least with default settings) always tells that user exists even if it is not so. Such behavior is common to many SMTP servers designed with security in mind since it is believed that lying about users existence helps to fight against spam. Does it mean that network checks in this module are useless? I think no since majority of SMTP servers do tell truth. Use this to filter email addresses. It was designed in such way that if there is exists possibility (even small) that email address is valid it will be treated as valid by this module.
Another warning is about $Mail::CheckUser::Treat_Timeout_As_Fail global variable. Use it carefully - if it set in true than some valid email addresses can be treated as bad simply SMTP server responds slowly.
EXAMPLE
This simple script checks if email address blabla@foo.bar is valid.
use Mail::CheckUser qw(check_email);
my $email = "blabla@foo.bar";
if(check_email($email)) {
print "E-mail address <$email> is OK\n";
} else {
print "E-mail address <$email> isn't valid\n";
}
GLOBAL VARIABLES
It is possible to configure check_email() using global variables listed below.
$Mail::CheckUser::Skip_Network_Checks - if it is true then do only syntax checks. By default it is false.
$Mail::CheckUser::Skip_SMTP_Checks - if it is true then do not try to connect to mail server to check if user exist on it. By default it is false.
$Mail::CheckUser::Sender_Addr - MAIL/RCPT check needs some mailbox name to perform its check. Default value is "check\@user.com"
$Mail::CheckUser::Helo_Domain - sender domain used in HELO SMTP command - if undef lets Net::SMTP use its default value. By default is is undef.
$Mail::CheckUser::Timeout - timeout in seconds for network checks. By default it is 60.
$Mail::CheckUser::Treat_Timeout_As_Fail - if it is true Mail::CheckUser treats timeouted checks as failed checks. By default it is false.
$Mail::CheckUser::Debug - if it is true then enable debug output on STDERR. By default it is false.
AUTHOR
Ilya Martynov m_ilya@agava.com
SEE ALSO
perl(1).