NAME
Email::Valid - Check validity of Internet e-mail addresses
SYNOPSIS
use Email::Valid;
print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no');
DESCRIPTION
This module determines whether an e-mail address is well-formed, and optionally, whether a mail host exists for the domain.
Please note that there is no way to definitely determine whether an address is deliverable without attempting delivery (for details, see perlfaq 9).
PREREQUISITES
The Mail::Address module is required.
Your system must have the nslookup utility in order to perform DNS checks.
METHODS
Every method which accepts an <ADDRESS> parameter may
be passed either a string or an instance of the Mail::Address
class.
- new ( [PARAMS] )
-
This method is used to construct an Email::Valid object. It accepts an optional list of named parameters to control the behavior of the object at instantiation.
The following named parameters are allowed. See the individual methods below of details.
-mxcheck -fudge -fqdn -local_rules
- mx ( <ADDRESS>|<DOMAIN> )
-
This method accepts an e-mail address or domain name, and determines whether a DNS records (A or MX record) exists for the domain.
The method returns true if a record is found, or undef if no record is found or an error is encountered.
DNS queries are currently performed using the 'nslookup' utility.
- rfc822 ( <ADDRESS> )
-
This method determines whether an address conforms to the RFC822 specification (except for nested comments). It returns true if it conforms, and undef if not.
- fudge ( <TRUE>|<FALSE> )
-
Specifies whether calls to address() should attempt to correct common addressing errors. Currently, this results in the removal of spaces in AOL addresses, and the conversion of commas to periods in Compuserve addresses. The default is false.
- fqdn ( <TRUE>|<FALSE> )
-
Species whether addresses passed to address() must contain a fully qualified domain name (FQDN). The default is true.
- local_rules ( <TRUE>|<FALSE> )
-
Specifies whether addresses passed to address() should be tested for domain specific restrictions. Currently, this is limited to certain AOL restrictions that I'm aware of. The default is true.
- mxcheck ( <TRUE>|<FALSE> )
-
Specifies whether addresses passed to address() should be checked for a valid DNS entry. The default is false.
- address ( <ADDRESS> )
-
This is the primary method, which determines whether an e-mail address is valid. It's behavior is modified by the values of mxcheck(), local_rules(), fqdn(), and fudge(). If the address passes all checks, the (possibly modified) address is returned. If the address does not pass a check, the undefined value is returned.
EXAMPLES
Let's see if the address 'maurice@hevanet.com' conforms to the RFC822 specification:
print (Email::Valid->address('maurice@hevanet.com') ? 'yes' : 'no');
Additionally, let's make sure there's a mail host for it:
print (Email::Valid->address( -address => 'maurice@hevanet.com',
-mxcheck => 1 ) ? 'yes' : 'no');
Let's see an example of how the address may be modified:
$addr = Email::Valid->address('Alfred Neuman <Neuman @ foo.bar>');
print "$addr\n"; # prints Neuman@foo.bar
BUGS
Other methods of performing DNS queries should be implemented, to increase portability.
AUTHOR
Copyright (C) 1998 Maurice Aubrey <maurice@hevanet.com>.
This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
Significant portions of this module are based on the ckaddr program written by Tom Christiansen and the RFC822 address pattern developed by Jeffrey Friedl. Neither were involved in the construction of this module; all errors are mine.
SEE ALSO
perl(1).