The Horde_Mime_Address:: class provides methods for dealing with email
address standards (RFC 822/2822/3490/5322).
Copyright 2008-2012 Horde LLC (http://www.horde.org/)
See the enclosed file COPYING for license information (LGPL). If you
did not receive this file, see http://www.horde.org/licenses/lgpl21.
Methods summary
public static
string
|
#
writeAddress( string $mailbox, string $host, string $personal = '', array $opts = array() )
Builds an RFC compliant email address.
Builds an RFC compliant email address.
Parameters
- $mailbox
- Mailbox name.
- $host
- Domain name of mailbox's host.
- $personal
- Personal name phrase.
- $opts
- <p>Additional options:
- idn: (boolean) If true, decode IDN domain names (Punycode/RFC 3490).
If false, convert domain names into IDN if necessary (@since
1.5.0).
If null, does no conversion.
Requires the idn or intl PHP module.
DEFAULT: true</p>
Returns
string The correctly escaped and quoted
"$personal <$mailbox@$host>" string.
|
public static
string
|
#
writeGroupAddress( string $groupname, array $addresses = array() )
Write an RFC compliant group address, given the group name and a list
of email addresses.
Write an RFC compliant group address, given the group name and a list
of email addresses.
Parameters
- $groupname
- The name of the group.
- $addresses
- <p>The component email addresses. These e-mail
addresses must be in RFC format.</p>
Returns
string The correctly quoted group string.
|
public static
string
|
#
trimAddress( string $address )
If an email address has no personal information, get rid of any angle
brackets (<>) around it.
If an email address has no personal information, get rid of any angle
brackets (<>) around it.
Parameters
- $address
- The address to trim.
Returns
string The trimmed address.
|
public static
array
|
#
explode( string $string, string $delimiters = ',' )
Explodes an RFC string, ignoring a delimiter if preceded by a "\"
character, or if the delimiter is inside single or double quotes.
Explodes an RFC string, ignoring a delimiter if preceded by a "\"
character, or if the delimiter is inside single or double quotes.
Parameters
- $string
- The RFC compliant string.
- $delimiters
- <p>A string containing valid delimiters.
Defaults to ','.</p>
Returns
array The exploded string in an array.
|
public static
string
|
#
addrObject2String( array $ob, array $opts = array() )
Takes an address object array and formats it as a string.
Takes an address object array and formats it as a string.
Object array format for the address "John Doe john_doe@example.com"
is: - host: The host the mailbox is on ("example.com") - mailbox: The user's mailbox ("john_doe") - personal: Personal name ("John Doe")
Parameters
- $ob
- The address object to be turned into a string.
- $opts
- <p>Additional options:
- charset: (string) The local charset.
DEFAULT: NONE
- filter: (mixed) A user@example.com style bare address to ignore.
Either single string or an array of strings. If the address
matches $filter, an empty string will be returned.
DEFAULT: No filter
- idn: (boolean) Convert IDN domain names (Punycode/RFC 3490) into
the local charset.
Requires the idn or intl PHP module.
DEFAULT: true</p>
Returns
string The formatted address.
|
public static
string
|
#
addrArray2String( array $addresses, array $opts = array() )
Takes an array of address object arrays and passes each of them through
addrObject2String().
Takes an array of address object arrays and passes each of them through
addrObject2String().
Parameters
- $addresses
- The array of address objects.
- $opts
- <p>Additional options:
- charset: (string) The local charset.
DEFAULT: NONE
- filter: (mixed) A user@example.com style bare address to ignore.
Either single string or an array of strings.
DEFAULT: No filter
- idn: (boolean) Convert IDN domain names (Punycode/RFC 3490) into
the local charset.
Requires the idn or intl PHP module.
DEFAULT: true</p>
Returns
string All of the addresses in a comma-delimited string.
Returns the empty string on error/no addresses found.
|
public static
array
|
#
getAddressesFromObject( array $obs, array $opts = array() )
Return the list of addresses for a header object.
Return the list of addresses for a header object.
Parameters
- $obs
- An array of header objects.
- $opts
- <p>Additional options:
- charset: (string) The local charset.
DEFAULT: NONE
- filter: (mixed) A user@example.com style bare address to ignore.
Either single string or an array of strings.
DEFAULT: No filter
- idn: (boolean) Convert IDN domain names (Punycode/RFC 3490) into
the local charset.
Requires the idn or intl PHP module.
DEFAULT: true</p>
Returns
array An array of address information. Array elements:
- address: (string) Full address
- display: (string) A displayable version of the address
- groupname: (string) The group name.
- host: (string) Hostname
- inner: (string) Trimmed, bare address
- personal: (string) Personal string
|
public static
mixed
|
#
bareAddress( string $address, string $defserver = null, boolean $multiple = false )
Returns the bare address.
Returns the bare address.
Parameters
- $address
- The address string.
- $defserver
- The default domain to append to mailboxes.
- $multiple
- Should we return multiple results?
Returns
mixed If $multiple is false, returns the mailbox@host e-mail
address. If $multiple is true, returns an array of
these addresses.
|
public static
array
|
#
parseAddressList( string $address, array $opts = array() )
Parses a list of email addresses into its parts. Handles distribution
lists.
Parses a list of email addresses into its parts. Handles distribution
lists.
Parameters
- $address
- The address string.
- $opts
- <p>Additional options:
- defserver: (string) The default domain to append to mailboxes.
DEFAULT: No domain appended.
- nestgroups: (boolean) Nest the groups? (Will appear under the
'groupname' key)
DEFAULT: No.
- validate: (boolean) Validate the address(es)?
DEFAULT: No.</p>
Returns
array A list of arrays with the possible keys: 'mailbox',
'host', 'personal', 'adl', 'groupname', and 'comment'.
Throws
|
public static
string
|
#
encode( string $str, string $type = 'address' )
Quotes and escapes the given string if necessary using rules contained
in RFC 2822 [3.2.5].
Quotes and escapes the given string if necessary using rules contained
in RFC 2822 [3.2.5].
Parameters
- $str
- The string to be quoted and escaped.
- $type
- Either 'address', or 'personal';
Returns
string The correctly quoted and escaped string.
|