$address
$address : string
The address being parsed by the RFC822 object.
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);
__construct(string $address = null, string $default_domain = null, boolean $nest_groups = null, boolean $validate = null, $limit = null) : object
Sets up the object. The address must either be set here or when calling parseAddressList(). One or the other.
| 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 |
Mail_RFC822 A new Mail_RFC822 object.
parseAddressList(string $address = null, string $default_domain = null, boolean $nest_groups = null, boolean $validate = null, $limit = null) : array
Starts the whole process. The address must either be set here or when creating the object. One or the other.
| 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 |
A structured array of addresses.
approximateCount(string $data) : integer
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().
| string | $data | Addresses to count |
Approximate count
isValidInetAddress(string $data, boolean $strict = false) : mixed
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.
| string | $data | Address to check |
| boolean | $strict | Optional stricter mode |
False if it fails, an indexed array username/domain if it matches
_splitCheck(array $parts, string $char) : mixed
A common function that will check an exploded string.
| array | $parts | The exloded string. |
| string | $char | The char that was exploded on. |
False if the string contains unclosed quotes/brackets, or the string on success.
_hasUnclosedBrackets(string $string, string $chars) : boolean
Checks if a string has an unclosed brackets or not. IMPORTANT: This function handles both angle brackets and square brackets;
| string | $string | The string to check. |
| string | $chars | The characters to check for. |
True if there are unclosed brackets inside the string, false otherwise.
_hasUnclosedBracketsSub(string $string, $num, string $char) : integer
Sub function that is used only by hasUnclosedBrackets().
| string | $string | The string to check. |
| $num | ||
| string | $char | The character to count. |
The number of occurences of $char in $string, adjusted for backslashes.
_validateAtom(string $atom) : boolean
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.
| string | $atom | The string to check. |
Success or failure.
_validateRouteAddr(string $route_addr) : mixed
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.
| string | $route_addr | The string to check. |
False on failure, or an array containing validated address/route information on success.
_validateDomain(string $domain) : mixed
Function to validate a domain, though this is not quite what you expect of a strict internet domain.
domain = sub-domain *("." sub-domain)
| string | $domain | The string to check. |
False on failure, or the validated domain on success.