Class Swift_Mime_Headers_MailboxHeader

InheritanceSwift_Mime_Headers_MailboxHeader » Swift_Mime_Headers_AbstractHeader
ImplementsSwift_Mime_Header

A Mailbox Address MIME Header for something like From or Sender.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Creates a new MailboxHeader with $name. Swift_Mime_Headers_MailboxHeader
__toString() Returns a string representation of this object. Swift_Mime_Headers_AbstractHeader
getAddresses() Get all email addresses in this Header. Swift_Mime_Headers_MailboxHeader
getCharset() Get the character set used in this Header. Swift_Mime_Headers_AbstractHeader
getEncoder() Get the encoder used for encoding this Header. Swift_Mime_Headers_AbstractHeader
getFieldBody() Get the string value of the body in this Header. Swift_Mime_Headers_MailboxHeader
getFieldBodyModel() Get the model for the field body. Swift_Mime_Headers_MailboxHeader
getFieldName() Get the name of this header (e.g. charset). Swift_Mime_Headers_AbstractHeader
getFieldType() Get the type of Header that this instance represents. Swift_Mime_Headers_MailboxHeader
getGrammar() Get the grammar used for this Header. Swift_Mime_Headers_AbstractHeader
getLanguage() Get the language used in this Header. Swift_Mime_Headers_AbstractHeader
getMaxLineLength() Get the maximum permitted length of lines in this Header. Swift_Mime_Headers_AbstractHeader
getNameAddressStrings() Get the full mailbox list of this Header as an array of valid RFC 2822 strings. Swift_Mime_Headers_MailboxHeader
getNameAddresses() Get all mailboxes in this Header as key=>value pairs. Swift_Mime_Headers_MailboxHeader
removeAddresses() Remove one or more addresses from this Header. Swift_Mime_Headers_MailboxHeader
setAddresses() Makes this Header represent a list of plain email addresses with no names. Swift_Mime_Headers_MailboxHeader
setCharset() Set the character set used in this Header. Swift_Mime_Headers_AbstractHeader
setEncoder() Set the encoder used for encoding the header. Swift_Mime_Headers_AbstractHeader
setFieldBodyModel() Set the model for the field body. Swift_Mime_Headers_MailboxHeader
setGrammar() Set the grammar used for the header. Swift_Mime_Headers_AbstractHeader
setLanguage() Set the language used in this Header. Swift_Mime_Headers_AbstractHeader
setMaxLineLength() Set the maximum length of lines in the header (excluding EOL). Swift_Mime_Headers_AbstractHeader
setNameAddresses() Set a list of mailboxes to be shown in this Header. Swift_Mime_Headers_MailboxHeader
toString() Get this Header rendered as a RFC 2822 compliant string. Swift_Mime_Headers_AbstractHeader

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
clearCachedValueIf() Clear the cached value if $condition is met. Swift_Mime_Headers_AbstractHeader
createDisplayNameString() Produces a compliant, formatted display-name based on the string given. Swift_Mime_Headers_MailboxHeader
createMailboxListString() Creates a string form of all the mailboxes in the passed array. Swift_Mime_Headers_MailboxHeader
createPhrase() Produces a compliant, formatted RFC 2822 'phrase' based on the string given. Swift_Mime_Headers_AbstractHeader
encodeWords() Encode needed word tokens within a string of input. Swift_Mime_Headers_AbstractHeader
generateTokenLines() Generates tokens from the given string which include CRLF as individual tokens. Swift_Mime_Headers_AbstractHeader
getCachedValue() Get the value in the cache. Swift_Mime_Headers_AbstractHeader
getEncodableWordTokens() Splits a string into tokens in blocks of words which can be encoded quickly. Swift_Mime_Headers_AbstractHeader
getTokenAsEncodedWord() Get a token as an encoded word for safe insertion into headers. Swift_Mime_Headers_AbstractHeader
normalizeMailboxes() Normalizes a user-input list of mailboxes into consistent key=>value pairs. Swift_Mime_Headers_MailboxHeader
setCachedValue() Set a value into the cache. Swift_Mime_Headers_AbstractHeader
setFieldName() Set the name of this Header field. Swift_Mime_Headers_AbstractHeader
toTokens() Generate a list of all tokens in the final header. Swift_Mime_Headers_AbstractHeader
tokenNeedsEncoding() Redefine the encoding requirements for mailboxes. Swift_Mime_Headers_MailboxHeader

Method Details

__construct() public method

Creates a new MailboxHeader with $name.

public void __construct ( $name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar )
$name string

Of Header

$encoder Swift_Mime_HeaderEncoder
$grammar Swift_Mime_Grammar
createDisplayNameString() protected method

Produces a compliant, formatted display-name based on the string given.

protected string createDisplayNameString ( $displayName, $shorten false )
$displayName string

As displayed

$shorten bool

The first line to make remove for header name

createMailboxListString() protected method

Creates a string form of all the mailboxes in the passed array.

protected string createMailboxListString ( array $mailboxes )
$mailboxes string[]
throws Swift_RfcComplianceException
getAddresses() public method

Get all email addresses in this Header.

See also getNameAddresses().

public string[] getAddresses ( )
getFieldBody() public method

Get the string value of the body in this Header.

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 string getFieldBody ( )
throws Swift_RfcComplianceException
getFieldBodyModel() public method

Get the model for the field body.

This method returns an associative array like {@link getNameAddresses()}

public array getFieldBodyModel ( )
throws Swift_RfcComplianceException
getFieldType() public method

Get the type of Header that this instance represents.

See also:

  • [[TYPE_TEXT,]] TYPE_PARAMETERIZED, TYPE_MAILBOX.
  • [[TYPE_DATE,]] TYPE_ID, TYPE_PATH.
public int getFieldType ( )
getNameAddressStrings() public method

Get the full mailbox list of this Header as an array of valid RFC 2822 strings.

Example: <?php $header = new Swift_Mime_Headers_MailboxHeader('From', array('chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn') ); print_r($header->getNameAddressStrings()); // array ( // 0 => Chris Corbyn chris@swiftmailer.org, // 1 => Mark Corbyn mark@swiftmailer.org // ) ?>

See also:

public string[] getNameAddressStrings ( )
throws Swift_RfcComplianceException
getNameAddresses() public method

Get all mailboxes in this Header as key=>value pairs.

The key is the address and the value is the name (or null if none set). Example: <?php $header = new Swift_Mime_Headers_MailboxHeader('From', array('chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn') ); print_r($header->getNameAddresses()); // array ( // chris@swiftmailer.org => Chris Corbyn, // mark@swiftmailer.org => Mark Corbyn // ) ?>

See also:

public string[] getNameAddresses ( )
normalizeMailboxes() protected method

Normalizes a user-input list of mailboxes into consistent key=>value pairs.

protected string[] normalizeMailboxes ( array $mailboxes )
$mailboxes string[]
removeAddresses() public method

Remove one or more addresses from this Header.

public void removeAddresses ( $addresses )
$addresses string|string[]
setAddresses() public method

Makes this Header represent a list of plain email addresses with no names.

Example: <?php //Sets three email addresses as the Header data $header->setAddresses( array('one@domain.tld', 'two@domain.tld', 'three@domain.tld') ); ?>

See also:

public void setAddresses ( $addresses )
$addresses string[]
throws Swift_RfcComplianceException
setFieldBodyModel() public method

Set the model for the field body.

This method takes a string, or an array of addresses.

public void setFieldBodyModel ( $model )
$model mixed
throws Swift_RfcComplianceException
setNameAddresses() public method

Set a list of mailboxes to be shown in this Header.

The mailboxes can be a simple array of addresses, or an array of key=>value pairs where (email => personalName). Example: <?php //Sets two mailboxes in the Header, one with a personal name $header->setNameAddresses(array( 'chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' //No associated personal name )); ?>

See also:

public void setNameAddresses ( $mailboxes )
$mailboxes string|string[]
throws Swift_RfcComplianceException
tokenNeedsEncoding() protected method

Redefine the encoding requirements for mailboxes.

Commas and semicolons are used to separate multiple addresses, and should therefore be encoded

protected bool tokenNeedsEncoding ( $token )
$token string