Mail::RFC822::Address(3pm)

Mail::RFC822::Address3pm

Perl extension for validating email addresses according to rfc822

Usage

  use Mail::RFC822::Address qw(valid validlist);
  if (valid("[email protected]")) {
      print "That's a valid address\n";
  }
  if (validlist("[email protected], [email protected]")) {
      print "That's a valid list of addresses\n";
  }

Overview

Mail::RFC822::Address validates email addresses against the grammar described in RFC 822 using regular expressions. How to validate a user supplied email address is a FAQ (see perlfaq9): the only sure way to see if a supplied email address is genuine is to send an email to it and see if the user recieves it. The one useful check that can be performed on an address is to check that the email address is syntactically valid. That is what this module does.

This module is functionally equivalent to RFC::RFC822::Address, but uses regular expressions rather than the Parse::RecDescent parser. This means that startup time is greatly reduced making it suitable for use in transient scripts such as CGI scripts.

valid ( address )

Returns true or false to indicate if address is an RFC822 valid address.

validlist ( addresslist )

In scalar context, returns true if the parameter is an RFC822 valid list of addresses.

In list context, returns an empty list on failure (an invalid address was found); otherwise a list whose first element is the number of addresses found and whose remaining elements are the addresses. This is needed to disambiguate failure (invalid) from success with no addresses found, because an empty string is a valid list.

Credits

Most of the test suite in test.pl is taken from RFC::RFC822::Address, written by Abigail, [email protected]

Releases

10 releases since Debian 4.0 (Etch); the text changed 5 times.

  1. 4.0
  2. 5.0
  3. 6.0–8
  4. 9–10
  5. 11
  6. 12–13

Author

Paul Warren, [email protected]

From libmail-rfc822-address-perl 0.4-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.