ICanBoogie
  • Documentation
  • API Reference
  • Mailer 1.1.x
Namespaces
  • ICanBoogie
    • Mailer
      • Header
Classes
  • AddressList
  • FileDeliverer
  • Header
  • MailDeliverer
  • Mailer
  • Message
  • MessagePart
Interfaces
  • Deliverer

Class AddressList

An address list.

<?php

use ICanBoogie\Mailer\AddressList;

$list = new AddressList;
$list[] = "olivier.laviale@gmail.com";
# or
$list["olivier.laviale@gmail.com"] = true;
# or, with a name
$list["olivier.laviale@gmail.com"] = "Olivier Laviale";

# Creating a collection from an array

$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']); // true
# remove mailbox
unset($list['person1@example.com']);
isset($list['person1@example.com']); // false
ICanBoogie\Mailer\AddressList implements ArrayAccess, IteratorAggregate

Direct known subclasses

ICanBoogie\Mailer\Header\AddressList

Indirect known subclasses

ICanBoogie\Mailer\Header\Bcc, ICanBoogie\Mailer\Header\Cc, ICanBoogie\Mailer\Header\From, ICanBoogie\Mailer\Header\To

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.

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

ICanBoogie\Mailer\AddressList

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

$address_list

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');    // "Joe Q. Public"
echo AddressList('Mary Smith');       // Mary Smith
echo AddressList('Who?');             // Who?
echo AddressList('Giant; "Big" Box'); // "Giant; \"Big\" Box"
echo AddressList('ACME, Inc.');       // "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() )

Initializes the ICanBoogie\Mailer\AddressList::$address_list property.

Initializes the ICanBoogie\Mailer\AddressList::$address_list property.

Note: The method uses the ArrayAccess interface to set the mailboxes.

Parameters

$address_list

An address list, such as one provided by the ICanBoogie\Mailer\AddressList::parse() method.

public offsetExists( string $mailbox ) : boolean

Checks if the recipient exists in the collection.

Checks if the recipient exists in the collection.

Parameters

$mailbox

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

$mailbox
$display_name

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.

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

string

An address-list string that can be parsed by the ICanBoogie\Mailer\AddressList::parse() method.

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()
Mailer 1.1.x – Check on GitHub – API documentation generated by ApiGen