PHP Class Swift_Mime_Headers_MailboxHeader

Author: Chris Corbyn
Inheritance: extends Swift_Mime_Headers_AbstractHeader
Datei anzeigen Open project: swiftmailer/swiftmailer Class Usage Examples

Public Methods

Method Description
__construct ( string $name, Swift_Mime_HeaderEncoder $encoder, Egulias\EmailValidator\EmailValidator $emailValidator ) Creates a new MailboxHeader with $name.
getAddresses ( ) : string[] Get all email addresses in this Header.
getFieldBody ( ) : string Get the string value of the body in this Header.
getFieldBodyModel ( ) : array Get the model for the field body.
getFieldType ( ) : integer Get the type of Header that this instance represents.
getNameAddressStrings ( ) : string[] Get the full mailbox list of this Header as an array of valid RFC 2822 strings.
getNameAddresses ( ) : string[] Get all mailboxes in this Header as key=>value pairs.
removeAddresses ( string | string[] $addresses ) Remove one or more addresses from this Header.
setAddresses ( string[] $addresses ) Makes this Header represent a list of plain email addresses with no names.
setFieldBodyModel ( mixed $model ) Set the model for the field body.
setNameAddresses ( string | string[] $mailboxes ) Set a list of mailboxes to be shown in this Header.

Protected Methods

Method Description
createDisplayNameString ( string $displayName, boolean $shorten = false ) : string Produces a compliant, formatted display-name based on the string given.
createMailboxListString ( array $mailboxes ) : string Creates a string form of all the mailboxes in the passed array.
normalizeMailboxes ( array $mailboxes ) : string[] Normalizes a user-input list of mailboxes into consistent key=>value pairs.
tokenNeedsEncoding ( string $token ) : boolean Redefine the encoding requirements for mailboxes.

Private Methods

Method Description
assertValidAddress ( string $address ) Throws an Exception if the address passed does not comply with RFC 2822.
createNameAddressStrings ( array $mailboxes ) : string[] Return an array of strings conforming the the name-addr spec of RFC 2822.

Method Details

__construct() public method

Creates a new MailboxHeader with $name.
public __construct ( string $name, Swift_Mime_HeaderEncoder $encoder, Egulias\EmailValidator\EmailValidator $emailValidator )
$name string of Header
$encoder Swift_Mime_HeaderEncoder
$emailValidator Egulias\EmailValidator\EmailValidator

createDisplayNameString() protected method

Produces a compliant, formatted display-name based on the string given.
protected createDisplayNameString ( string $displayName, boolean $shorten = false ) : string
$displayName string as displayed
$shorten boolean the first line to make remove for header name
return string

createMailboxListString() protected method

Creates a string form of all the mailboxes in the passed array.
protected createMailboxListString ( array $mailboxes ) : string
$mailboxes array
return string

getAddresses() public method

Get all email addresses in this Header.
See also: getNameAddresses()
public getAddresses ( ) : string[]
return string[]

getFieldBody() public method

This is not necessarily RFC 2822 compliant since folding white space will not be added at this stage (see {@link toString()} for that).
See also: toString()
public getFieldBody ( ) : string
return string

getFieldBodyModel() public method

This method returns an associative array like {@link getNameAddresses()}
public getFieldBodyModel ( ) : array
return array

getFieldType() public method

Get the type of Header that this instance represents.
public getFieldType ( ) : integer
return integer

getNameAddressStrings() public method

Example: 'Chris Corbyn', '[email protected]' => 'Mark Corbyn') ); print_r($header->getNameAddressStrings()); array ( 0 => Chris Corbyn , 1 => Mark Corbyn ) ?>
See also: getNameAddresses()
See also: toString()
public getNameAddressStrings ( ) : string[]
return string[]

getNameAddresses() public method

The key is the address and the value is the name (or null if none set). Example: 'Chris Corbyn', '[email protected]' => 'Mark Corbyn') ); print_r($header->getNameAddresses()); array ( [email protected] => Chris Corbyn, [email protected] => Mark Corbyn ) ?>
See also: getAddresses()
See also: getNameAddressStrings()
public getNameAddresses ( ) : string[]
return string[]

normalizeMailboxes() protected method

Normalizes a user-input list of mailboxes into consistent key=>value pairs.
protected normalizeMailboxes ( array $mailboxes ) : string[]
$mailboxes array
return string[]

removeAddresses() public method

Remove one or more addresses from this Header.
public removeAddresses ( string | string[] $addresses )
$addresses string | string[]

setAddresses() public method

Example: setAddresses( array('[email protected]', '[email protected]', '[email protected]') ); ?>
See also: setNameAddresses()
See also: setValue()
public setAddresses ( string[] $addresses )
$addresses string[]

setFieldBodyModel() public method

This method takes a string, or an array of addresses.
public setFieldBodyModel ( mixed $model )
$model mixed

setNameAddresses() public method

The mailboxes can be a simple array of addresses, or an array of key=>value pairs where (email => personalName). Example: setNameAddresses(array( '[email protected]' => 'Chris Corbyn', '[email protected]' //No associated personal name )); ?>
See also: __construct()
See also: setAddresses()
See also: setValue()
public setNameAddresses ( string | string[] $mailboxes )
$mailboxes string | string[]

tokenNeedsEncoding() protected method

All "specials" must be encoded as the full header value will not be quoted
See also: RFC 2822 3.2.1
protected tokenNeedsEncoding ( string $token ) : boolean
$token string
return boolean