Class AddressList
An address list.
<?php
use ICanBoogie\Mailer\AddressList;
$list = new AddressList;
$list[] = "olivier.laviale@gmail.com";
$list["olivier.laviale@gmail.com"] = true;
$list["olivier.laviale@gmail.com"] = "Olivier Laviale";
$list = new AddressList([
'person1@example.com',
'person2@example.org',
'person3@example.net' => 'Person 3 Name',
'person4@example.org',
'person5@example.net' => 'Person 5 Name'
]);
isset($list['person1@example.com']);
unset($list['person1@example.com']);
isset($list['person1@example.com']);
-
ICanBoogie\Mailer\AddressList
implements
ArrayAccess,
IteratorAggregate
Namespace: ICanBoogie\
Mailer
See:
http://tools.ietf.org/html/rfc5322#section-3.4
Located at AddressList.php
Methods summary
public static
from( string|array|ICanBoogie\Mailer\AddressList
$address_list
)
: ICanBoogie\Mailer\AddressList
Creates a ICanBoogie\Mailer\AddressList
instance from the provided source.
Parameters
$address_list
The address list can be specified as a string,
an array or an ICanBoogie\Mailer\AddressList
instance.
While specified as a string, the address list must be separated by a comma. The display-name of
the address can be defined using the following notation : "display-name ", where
display-name
is the name of the recipient and email
is its email address.
Returns
See
http://tools.ietf.org/html/rfc5322#section-3.4
public static
parse( string $address_list
)
: array[string]string
Parses an address-list string and returns an array of mailbox/display-name pairs.
Parses an address-list string and returns an array of mailbox/display-name pairs.
Parameters
Returns
array[string]string
An array where each key/value pair represents a mailbox
and a display-name, or an integer and a mailbox.
public static
escape_display_name( string $display_name
)
: string
Escapes the specified display name according to the specification.
Escapes the specified display name according to the specification.
<?php
use ICanBoogie\Mailer\AddressList;
echo AddressList('Joe Q. Public');
echo AddressList('Mary Smith');
echo AddressList('Who?');
echo AddressList('Giant; "Big" Box');
echo AddressList('ACME, Inc.');
Parameters
$display_name
- The display name to escape.
Returns
string
See
http://tools.ietf.org/html/rfc5322#section-3.2.3
http://tools.ietf.org/html/rfc5322#appendix-A.1.2
public
__construct( array $address_list
= array() )
public
offsetExists( string $mailbox
)
: boolean
Checks if the recipient exists in the collection.
Checks if the recipient exists in the collection.
Parameters
Returns
boolean
true
if the recipient exists, false
otherwise.
Implementation of
ArrayAccess::offsetExists()
public
offsetSet( string $mailbox
, string $display_name
)
Adds or sets a recipient.
Adds or sets a recipient.
Parameters
Throws
InvalidArgumentException
when $mailbox
is not a valid email address.
Implementation of
ArrayAccess::offsetSet()
public
offsetGet( string $mailbox
)
: string
Returns the recipient name.
Returns the recipient name.
Parameters
$mailbox
- The email of the recipient.
Returns
string
Implementation of
ArrayAccess::offsetGet()
public
offsetUnset( string $mailbox
)
Removes a recipient.
Parameters
$mailbox
- The email of the recipient.
Implementation of
ArrayAccess::offsetUnset()
public
getIterator( void )
: ArrayIterator
Returns
ArrayIterator
Implementation of
IteratorAggregate::getIterator()
public
__toString( void )
: string
Returns a string representation of the instance.
Returns a string representation of the instance.
Note: The returned string is not suitable for a header field,
use a ICanBoogie\Mailer\Header\AddressList
instance for that.
Returns
Properties summary
protected
$address_list
: array
A collection of recipient.
A collection of recipient.
Each key/value pair represents a mailbox and a display-name, which might be true
if
the display-name of mailbox was not provided.
array()