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

Class: Mail_RFC822

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

Class Overview


RFC 822 Email address list validation Utility


Author(s):

Version:

  • $Revision$

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 70]
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 76]

The address being parsed by the RFC822 object.

Type:   string


[ Top ]

$addresses = array()

[line 100]

The array of raw addresses built up as we parse.

Type:   array


[ Top ]

$default_domain =  'localhost'

[line 82]

The default domain to use for unqualified addresses.

Type:   string


[ Top ]

$error =  null

[line 112]

The current error message, if any.

Type:   string


[ Top ]

$index =  null

[line 118]

An internal counter/pointer.

Type:   integer


[ Top ]

$limit =  null

[line 138]

A limit after which processing stops

Type:   int


[ Top ]

$mailRFC822 =  true

[line 132]

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

Type:   boolean


[ Top ]

$nestGroups =  true

[line 88]

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

Type:   boolean


[ Top ]

$num_groups =  0

[line 125]

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

Type:   integer


[ Top ]

$structure = array()

[line 106]

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

Type:   array


[ Top ]

$validate =  true

[line 94]

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

Type:   boolean


[ Top ]



Method Detail

__construct (Constructor)   [line 151]

object Mail_RFC822 __construct( [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 899]

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
  • Access: public

Parameters:

string   $data   —  Addresses to count

[ Top ]

isValidInetAddress   [line 917]

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
  • Access: public

Parameters:

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

[ Top ]

parseAddressList   [line 171]

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 609]

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 ]

_hasUnclosedBrackets   [line 393]

boolean _hasUnclosedBrackets( string $string, string $chars)

Checks if a string has an unclosed brackets or not. IMPORTANT: This function handles both angle brackets and square brackets;
  • Return: True if there are unclosed brackets inside the string, false otherwise.
  • Access: protected

Parameters:

string   $string   —  The string to check.
string   $chars   —  The characters to check for.

[ Top ]

_hasUnclosedBracketsSub   [line 417]

integer _hasUnclosedBracketsSub( string $string, integer &$num, string $char)

Sub function that is used only by hasUnclosedBrackets().
  • Return: The number of occurences of $char in $string, adjusted for backslashes.
  • Access: protected

Parameters:

string   $string   —  The string to check.
integer   &$num   —  The number of occurences.
string   $char   —  The character to count.

[ Top ]

_hasUnclosedQuotes   [line 357]

boolean _hasUnclosedQuotes( string $string)

Checks if a string has unclosed quotes or not.
  • Return: True if there are unclosed quotes inside the string, false otherwise.
  • Access: protected

Parameters:

string   $string   —  The string to check.

[ Top ]

_isGroup   [line 301]

boolean _isGroup( string $address)

Checks for a group at the start of the string.
  • Return: Whether or not there is a group at the start of the string.
  • Access: protected

Parameters:

string   $address   —  The address to check.

[ Top ]

_splitAddresses   [line 226]

boolean _splitAddresses( string $address)

Splits an address into separate addresses.
  • Return: Success or failure.
  • Access: protected

Parameters:

string   $address   —  The addresses to split.

[ Top ]

_splitCheck   [line 325]

mixed _splitCheck( array $parts, string $char)

A common function that will check an exploded string.
  • Return: False if the string contains unclosed quotes/brackets, or the string on success.
  • Access: protected

Parameters:

array   $parts   —  The exloded string.
string   $char   —  The char that was exploded on.

[ Top ]

_validateAddress   [line 436]

mixed _validateAddress( string $address)

Function to begin checking the address.
  • Return: False on failure, or a structured array of address information on success.
  • Access: protected

Parameters:

string   $address   —  The address to validate.

[ Top ]

_validateAddrSpec   [line 827]

mixed _validateAddrSpec( string $addr_spec)

Function to validate an addr-spec.

addr-spec = local-part "@" domain

  • Return: False on failure, or the validated addr-spec on success.
  • Access: protected

Parameters:

string   $addr_spec   —  The string to check.

[ Top ]

_validateAtom   [line 560]

boolean _validateAtom( string $atom)

Function to validate an atom which from rfc822 is: atom = 1*<any CHAR except specials, SPACE and CTLs>

If validation ($this->validate) has been turned off, then validateAtom() doesn't actually check anything. This is so that you can split a list of addresses up before encoding personal names (umlauts, etc.), for example.

  • Return: Success or failure.
  • Access: protected

Parameters:

string   $atom   —  The string to check.

[ Top ]

_validateDliteral   [line 814]

boolean _validateDliteral( string $dliteral)

Function to validate a domain literal: domain-literal = "[" *(dtext / quoted-pair) "]"
  • Return: Success or failure.
  • Access: protected

Parameters:

string   $dliteral   —  The string to check.

[ Top ]

_validateDomain   [line 768]

mixed _validateDomain( string $domain)

Function to validate a domain, though this is not quite what you expect of a strict internet domain.

domain = sub-domain *("." sub-domain)

  • Return: False on failure, or the validated domain on success.
  • Access: protected

Parameters:

string   $domain   —  The string to check.

[ Top ]

_validateLocalPart   [line 857]

mixed _validateLocalPart( string $local_part)

Function to validate the local part of an address: local-part = word *("." word)
  • Return: False on failure, or the validated local part on success.
  • Access: protected

Parameters:

string   $local_part   — 

[ Top ]

_validatePhrase   [line 520]

boolean _validatePhrase( string $phrase)

Function to validate a phrase.
  • Return: Success or failure.
  • Access: protected

Parameters:

string   $phrase   —  The phrase to check.

[ Top ]

_validateQuotedString   [line 592]

boolean _validateQuotedString( string $qstring)

Function to validate quoted string, which is: quoted-string = <"> *(qtext/quoted-pair) <">
  • Return: Success or failure.
  • Access: protected

Parameters:

string   $qstring   —  The string to check

[ Top ]

_validateRoute   [line 746]

mixed _validateRoute( string $route)

Function to validate a route, which is: route = 1#("@" domain) ":"
  • Return: False on failure, or the validated $route on success.
  • Access: protected

Parameters:

string   $route   —  The string to check.

[ Top ]

_validateRouteAddr   [line 697]

mixed _validateRouteAddr( string $route_addr)

This function validates a route-addr which is: route-addr = "<" [route] addr-spec ">"

Angle brackets have already been removed at the point of getting to this function.

  • Return: False on failure, or an array containing validated address/route information on success.
  • Access: protected

Parameters:

string   $route_addr   —  The string to check.

[ Top ]

_validateSubdomain   [line 795]

boolean _validateSubdomain( string $subdomain)

Function to validate a subdomain: subdomain = domain-ref / domain-literal
  • Return: Success or failure.
  • Access: protected

Parameters:

string   $subdomain   —  The string to check.

[ Top ]


Documentation generated on Sun, 31 Jan 2016 22:00:02 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.