Class src_mail_RFC822

Description

RFC 822 Email address list validation Utility

What is it?

This class will take an address string, and parse it into it's consituent parts, be that either addresses, groups, or combinations. Nested groups are not supported. The structure it returns is pretty straight forward, and is similar to that provided by the imap_rfc822_parse_adrlist(). Use print_r() to view the structure.

How do I use it?

$address_string = 'My Group: "Richard Heyes" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;'; $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', TRUE) print_r($structure);

Located in /src/mail/class.RFC822.php (line 27)


	
			
Method Summary
object Mail_RFC822 __construct ([string $address = null], [string $default_domain = null], [boolean $nest_groups = null], [boolean $validate = null], [ $limit = null])
int approximateCount (string $data)
mixed isValidInetAddress (string $data, [boolean $strict = false])
array parseAddressList ([string $address = null], [string $default_domain = null], [boolean $nest_groups = null], [boolean $validate = null], [ $limit = null])
boolean validateMailbox (string &$mailbox)
Methods
Constructor __construct (line 108)

Sets up the object. The address must either be set here or when calling parseAddressList(). One or the other.

  • return: A new Mail_RFC822 object.
  • access: public
object Mail_RFC822 __construct ([string $address = null], [string $default_domain = null], [boolean $nest_groups = null], [boolean $validate = null], [ $limit = null])
  • string $address: The address(es) to validate.
  • string $default_domain: Default domain/host etc. If not supplied, will be set to localhost.
  • boolean $nest_groups: Whether to return the structure with groups nested for easier viewing.
  • boolean $validate: Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
  • $limit
approximateCount (line 839)

Returns an approximate count of how many addresses are

in the given string. This is APPROXIMATE as it only splits based on a comma which has no preceding backslash. Could be useful as large amounts of addresses will end up producing *large* structures when used with parseAddressList().

  • return: Approximate count
int approximateCount (string $data)
  • string $data: Addresses to count
isValidInetAddress (line 856)

This is a email validating function seperate to the rest

of the class. It simply validates whether an email is of the common internet form: <user>@<domain>. This can be sufficient for most people. Optional stricter mode can be utilised which restricts mailbox characters allowed to alphanumeric, full stop, hyphen and underscore.

  • return: False if it fails, an indexed array username/domain if it matches
mixed isValidInetAddress (string $data, [boolean $strict = false])
  • string $data: Address to check
  • boolean $strict: Optional stricter mode
parseAddressList (line 133)

Starts the whole process. The address must either be set here or when creating the object. One or the other.

  • return: A structured array of addresses.
  • access: public
array parseAddressList ([string $address = null], [string $default_domain = null], [boolean $nest_groups = null], [boolean $validate = null], [ $limit = null])
  • string $address: The address(es) to validate.
  • string $default_domain: Default domain/host etc.
  • boolean $nest_groups: Whether to return the structure with groups nested for easier viewing.
  • boolean $validate: Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
  • $limit
validateMailbox (line 557)

Function to validate a mailbox, which is: mailbox = addr-spec ; simple address / phrase route-addr ; name and route-addr

  • return: Success or failure.
  • access: public
boolean validateMailbox (string &$mailbox)
  • string &$mailbox: The string to check.

Documentation generated on Sat, 24 Mar 2007 09:59:56 +0100 by phpDocumentor 1.3.1