SYNOPSIS

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

DESCRIPTION

Mail::RFC822::Address validates email addresses against the grammar described in \s-1RFC\s0 822 using regular expressions. How to validate a user supplied email address is a \s-1FAQ\s0 (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 \s-1CGI\s0 scripts.

valid ( address )

Returns true or false to indicate if address is an \s-1RFC822\s0 valid address.

validlist ( addresslist )

In scalar context, returns true if the parameter is an \s-1RFC822\s0 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.

AUTHOR

Paul Warren, [email protected]

CREDITS

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

COPYRIGHT and LICENSE

This program is copyright 2001-2002 by Paul Warren.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \*(L"Software\*(R"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

\s-1THE\s0 \s-1SOFTWARE\s0 \s-1IS\s0 \s-1PROVIDED\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R", \s-1WITHOUT\s0 \s-1WARRANTY\s0 \s-1OF\s0 \s-1ANY\s0 \s-1KIND\s0, \s-1EXPRESS\s0 \s-1OR\s0 \s-1IMPLIED\s0, \s-1INCLUDING\s0 \s-1BUT\s0 \s-1NOT\s0 \s-1LIMITED\s0 \s-1TO\s0 \s-1THE\s0 \s-1WARRANTIES\s0 \s-1OF\s0 \s-1MERCHANTABILITY\s0, \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0 \s-1AND\s0 \s-1NONINFRINGEMENT\s0. \s-1IN\s0 \s-1NO\s0 \s-1EVENT\s0 \s-1SHALL\s0 \s-1THE\s0 \s-1AUTHOR\s0 \s-1BE\s0 \s-1LIABLE\s0 \s-1FOR\s0 \s-1ANY\s0 \s-1CLAIM\s0, \s-1DAMAGES\s0 \s-1OR\s0 \s-1OTHER\s0 \s-1LIABILITY\s0, \s-1WHETHER\s0 \s-1IN\s0 \s-1AN\s0 \s-1ACTION\s0 \s-1OF\s0 \s-1CONTRACT\s0, \s-1TORT\s0 \s-1OR\s0 \s-1OTHERWISE\s0, \s-1ARISING\s0 \s-1FROM\s0, \s-1OUT\s0 \s-1OF\s0 \s-1OR\s0 \s-1IN\s0 \s-1CONNECTION\s0 \s-1WITH\s0 \s-1THE\s0 \s-1SOFTWARE\s0 \s-1OR\s0 \s-1THE\s0 \s-1USE\s0 \s-1OR\s0 \s-1OTHER\s0 \s-1DEALINGS\s0 \s-1IN\s0 \s-1THE\s0 \s-1SOFTWARE\s0.

RELATED TO Mail::RFC822::Address…

RFC::RFC822::Address, Mail::Address