Mail
[ class tree: Mail ] [ index: Mail ] [ all elements ]

Class: Mail_RFC822

Source Location: /Mail-1.1.14/Mail/RFC822.php

Class Overview


RFC 822 Email address list validation Utility


Author(s):

Version:

  • $Revision: 1.23 $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 59]
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" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;'; $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true) print_r($structure);



[ Top ]


Class Variables

$address =  ''

[line 65]

The address being parsed by the RFC822 object.

Type:   string


[ Top ]

$addresses = array()

[line 89]

The array of raw addresses built up as we parse.

Type:   array


[ Top ]

$default_domain =  'localhost'

[line 71]

The default domain to use for unqualified addresses.

Type:   string


[ Top ]

$error =  null

[line 101]

The current error message, if any.

Type:   string


[ Top ]

$index =  null

[line 107]

An internal counter/pointer.

Type:   integer


[ Top ]

$limit =  null

[line 127]

A limit after which processing stops

Type:   int


[ Top ]

$mailRFC822 =  true

[line 121]

A variable so that we can tell whether or not we're inside a Mail_RFC822 object.

Type:   boolean


[ Top ]

$nestGroups =  true

[line 77]

Should we return a nested array showing groups, or flatten everything?

Type:   boolean


[ Top ]

$num_groups =  0

[line 114]

The number of groups that have been found in the address list.
  • Access: public

Type:   integer


[ Top ]

$structure = array()

[line 95]

The final array of parsed address information that we build up.

Type:   array


[ Top ]

$validate =  true

[line 83]

Whether or not to validate atoms for non-ascii characters.

Type:   boolean


[ Top ]



Method Detail

Mail_RFC822 (Constructor)   [line 141]

object Mail_RFC822 Mail_RFC822( [string $address = null], [string $default_domain = null], [boolean $nest_groups = null], [boolean $validate = null], [ $limit = null])

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

Parameters:

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   — 

[ Top ]

approximateCount   [line 895]

int approximateCount( string $data)

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

Parameters:

string   $data   —  Addresses to count

[ Top ]

isValidInetAddress   [line 913]

mixed isValidInetAddress( string $data, [boolean $strict = false])

This is a email validating function separate 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

Parameters:

string   $data   —  Address to check
boolean   $strict   —  Optional stricter mode

[ Top ]

parseAddressList   [line 162]

array parseAddressList( [string $address = null], [string $default_domain = null], [boolean $nest_groups = null], [boolean $validate = null], [ $limit = null])

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

Parameters:

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   — 

[ Top ]

validateMailbox   [line 602]

boolean validateMailbox( string &$mailbox)

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

Parameters:

string   &$mailbox   —  The string to check.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:46:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.