Swift_Mime_Headers_MailboxHeader
extends Swift_Mime_Headers_AbstractHeader
in package
A Mailbox Address MIME Header for something like From or Sender.
Tags
Table of Contents
- PHRASE_PATTERN = '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?)|(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?"((?:(?:[ \t]*(?:\r\n))?[ \t])?(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21\x23-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])))*(?:(?:[ \t]*(?:\r\n))?[ \t])?"(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'
- $addressEncoder : mixed
- $cachedValue : string
- The value of this Header, cached.
- $charset : string
- The character set of the text in this Header.
- $emailValidator : EmailValidator
- The strict EmailValidator.
- $encoder : Swift_Encoder
- The Encoder used to encode this Header.
- $lang : string
- The language used in this Header.
- $lineLength : int
- The maximum length of a line in the header.
- $mailboxes : array<string|int, string>
- The mailboxes used in this Header.
- $name : string
- The name of this Header.
- __construct() : mixed
- Creates a new MailboxHeader with $name.
- __toString() : string
- Returns a string representation of this object.
- getAddresses() : array<string|int, string>
- Get all email addresses in this Header.
- getCharset() : string
- Get the character set used in this Header.
- getEncoder() : Swift_Mime_HeaderEncoder
- Get the encoder used for encoding this Header.
- getFieldBody() : string
- Get the string value of the body in this Header.
- getFieldBodyModel() : array<string|int, mixed>
- Get the model for the field body.
- getFieldName() : string
- Get the name of this header (e.g. charset).
- getFieldType() : int
- Get the type of Header that this instance represents.
- getLanguage() : string
- Get the language used in this Header.
- getMaxLineLength() : int
- Get the maximum permitted length of lines in this Header.
- getNameAddresses() : array<string|int, string>
- Get all mailboxes in this Header as key=>value pairs.
- getNameAddressStrings() : array<string|int, string>
- Get the full mailbox list of this Header as an array of valid RFC 2822 strings.
- removeAddresses() : mixed
- Remove one or more addresses from this Header.
- setAddresses() : mixed
- Makes this Header represent a list of plain email addresses with no names.
- setCharset() : mixed
- Set the character set used in this Header.
- setEncoder() : mixed
- Set the encoder used for encoding the header.
- setFieldBodyModel() : mixed
- Set the model for the field body.
- setLanguage() : mixed
- Set the language used in this Header.
- setMaxLineLength() : mixed
- Set the maximum length of lines in the header (excluding EOL).
- setNameAddresses() : mixed
- Set a list of mailboxes to be shown in this Header.
- toString() : string
- Get this Header rendered as a RFC 2822 compliant string.
- clearCachedValueIf() : mixed
- Clear the cached value if $condition is met.
- createDisplayNameString() : string
- Produces a compliant, formatted display-name based on the string given.
- createMailboxListString() : string
- Creates a string form of all the mailboxes in the passed array.
- createPhrase() : string
- Produces a compliant, formatted RFC 2822 'phrase' based on the string given.
- encodeWords() : string
- Encode needed word tokens within a string of input.
- generateTokenLines() : array<string|int, string>
- Generates tokens from the given string which include CRLF as individual tokens.
- getCachedValue() : string
- Get the value in the cache.
- getEncodableWordTokens() : array<string|int, string>
- Splits a string into tokens in blocks of words which can be encoded quickly.
- getTokenAsEncodedWord() : string
- Get a token as an encoded word for safe insertion into headers.
- normalizeMailboxes() : array<string|int, string>
- Normalizes a user-input list of mailboxes into consistent key=>value pairs.
- setCachedValue() : mixed
- Set a value into the cache.
- setFieldName() : mixed
- Set the name of this Header field.
- tokenNeedsEncoding() : bool
- Redefine the encoding requirements for mailboxes.
- toTokens() : array<string|int, mixed>
- Generate a list of all tokens in the final header.
- assertValidAddress() : mixed
- Throws an Exception if the address passed does not comply with RFC 2822.
- createNameAddressStrings() : array<string|int, string>
- Return an array of strings conforming the the name-addr spec of RFC 2822.
- escapeSpecials() : string
- Escape special characters in a string (convert to quoted-pairs).
- tokensToString() : string
- Takes an array of tokens which appear in the header and turns them into an RFC 2822 compliant string, adding FWSP where needed.
Constants
PHRASE_PATTERN
public
mixed
PHRASE_PATTERN
= '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]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x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'
Properties
$addressEncoder
private
mixed
$addressEncoder
$cachedValue
The value of this Header, cached.
private
string
$cachedValue
=
ull
$charset
The character set of the text in this Header.
private
string
$charset
= 'utf-8'
$emailValidator
The strict EmailValidator.
private
EmailValidator
$emailValidator
$encoder
The Encoder used to encode this Header.
private
Swift_Encoder
$encoder
$lang
The language used in this Header.
private
string
$lang
$lineLength
The maximum length of a line in the header.
private
int
$lineLength
= 78
$mailboxes
The mailboxes used in this Header.
private
array<string|int, string>
$mailboxes
= []
$name
The name of this Header.
private
string
$name
Methods
__construct()
Creates a new MailboxHeader with $name.
public
__construct(string $name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator[, Swift_AddressEncoder $addressEncoder = null ]) : mixed
Parameters
- $name : string
-
of Header
- $encoder : Swift_Mime_HeaderEncoder
- $emailValidator : EmailValidator
- $addressEncoder : Swift_AddressEncoder = null
Return values
mixed —__toString()
Returns a string representation of this object.
public
__toString() : string
Tags
Return values
string —getAddresses()
Get all email addresses in this Header.
public
getAddresses() : array<string|int, string>
Tags
Return values
array<string|int, string> —getCharset()
Get the character set used in this Header.
public
getCharset() : string
Return values
string —getEncoder()
Get the encoder used for encoding this Header.
public
getEncoder() : Swift_Mime_HeaderEncoder
Return values
Swift_Mime_HeaderEncoder —getFieldBody()
Get the string value of the body in this Header.
public
getFieldBody() : string
This is not necessarily RFC 2822 compliant since folding white space will not be added at this stage (see for that).
Tags
Return values
string —getFieldBodyModel()
Get the model for the field body.
public
getFieldBodyModel() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getFieldName()
Get the name of this header (e.g. charset).
public
getFieldName() : string
Return values
string —getFieldType()
Get the type of Header that this instance represents.
public
getFieldType() : int
Tags
Return values
int —getLanguage()
Get the language used in this Header.
public
getLanguage() : string
Return values
string —getMaxLineLength()
Get the maximum permitted length of lines in this Header.
public
getMaxLineLength() : int
Return values
int —getNameAddresses()
Get all mailboxes in this Header as key=>value pairs.
public
getNameAddresses() : array<string|int, string>
The key is the address and the value is the name (or null if none set).
Example:
Tags
Return values
array<string|int, string> —getNameAddressStrings()
Get the full mailbox list of this Header as an array of valid RFC 2822 strings.
public
getNameAddressStrings() : array<string|int, string>
Example:
Tags
Return values
array<string|int, string> —removeAddresses()
Remove one or more addresses from this Header.
public
removeAddresses(string|array<string|int, string> $addresses) : mixed
Parameters
- $addresses : string|array<string|int, string>
Return values
mixed —setAddresses()
Makes this Header represent a list of plain email addresses with no names.
public
setAddresses(array<string|int, string> $addresses) : mixed
Example:
Parameters
- $addresses : array<string|int, string>
Tags
Return values
mixed —setCharset()
Set the character set used in this Header.
public
setCharset(string $charset) : mixed
Parameters
- $charset : string
Return values
mixed —setEncoder()
Set the encoder used for encoding the header.
public
setEncoder(Swift_Mime_HeaderEncoder $encoder) : mixed
Parameters
- $encoder : Swift_Mime_HeaderEncoder
Return values
mixed —setFieldBodyModel()
Set the model for the field body.
public
setFieldBodyModel(mixed $model) : mixed
This method takes a string, or an array of addresses.
Parameters
- $model : mixed
Tags
Return values
mixed —setLanguage()
Set the language used in this Header.
public
setLanguage(string $lang) : mixed
For example, for US English, 'en-us'. This can be unspecified.
Parameters
- $lang : string
Return values
mixed —setMaxLineLength()
Set the maximum length of lines in the header (excluding EOL).
public
setMaxLineLength(int $lineLength) : mixed
Parameters
- $lineLength : int
Return values
mixed —setNameAddresses()
Set a list of mailboxes to be shown in this Header.
public
setNameAddresses(string|array<string|int, string> $mailboxes) : mixed
The mailboxes can be a simple array of addresses, or an array of
key=>value pairs where (email => personalName).
Example:
Parameters
- $mailboxes : string|array<string|int, string>
Tags
Return values
mixed —toString()
Get this Header rendered as a RFC 2822 compliant string.
public
toString() : string
Tags
Return values
string —clearCachedValueIf()
Clear the cached value if $condition is met.
protected
clearCachedValueIf(bool $condition) : mixed
Parameters
- $condition : bool
Return values
mixed —createDisplayNameString()
Produces a compliant, formatted display-name based on the string given.
protected
createDisplayNameString(string $displayName[, bool $shorten = false ]) : string
Parameters
- $displayName : string
-
as displayed
- $shorten : bool = false
-
the first line to make remove for header name
Return values
string —createMailboxListString()
Creates a string form of all the mailboxes in the passed array.
protected
createMailboxListString(array<string|int, string> $mailboxes) : string
Parameters
- $mailboxes : array<string|int, string>
Tags
Return values
string —createPhrase()
Produces a compliant, formatted RFC 2822 'phrase' based on the string given.
protected
createPhrase(Swift_Mime_Header $header, string $string, string $charset[, Swift_Mime_HeaderEncoder $encoder = null ][, bool $shorten = false ]) : string
Parameters
- $header : Swift_Mime_Header
- $string : string
-
as displayed
- $charset : string
-
of the text
- $encoder : Swift_Mime_HeaderEncoder = null
- $shorten : bool = false
-
the first line to make remove for header name
Return values
string —encodeWords()
Encode needed word tokens within a string of input.
protected
encodeWords(Swift_Mime_Header $header, string $input[, string $usedLength = -1 ]) : string
Parameters
- $header : Swift_Mime_Header
- $input : string
- $usedLength : string = -1
-
optional
Return values
string —generateTokenLines()
Generates tokens from the given string which include CRLF as individual tokens.
protected
generateTokenLines(string $token) : array<string|int, string>
Parameters
- $token : string
Return values
array<string|int, string> —getCachedValue()
Get the value in the cache.
protected
getCachedValue() : string
Return values
string —getEncodableWordTokens()
Splits a string into tokens in blocks of words which can be encoded quickly.
protected
getEncodableWordTokens(string $string) : array<string|int, string>
Parameters
- $string : string
Return values
array<string|int, string> —getTokenAsEncodedWord()
Get a token as an encoded word for safe insertion into headers.
protected
getTokenAsEncodedWord(string $token, int $firstLineOffset) : string
Parameters
- $token : string
-
token to encode
- $firstLineOffset : int
-
optional
Return values
string —normalizeMailboxes()
Normalizes a user-input list of mailboxes into consistent key=>value pairs.
protected
normalizeMailboxes(array<string|int, string> $mailboxes) : array<string|int, string>
Parameters
- $mailboxes : array<string|int, string>
Return values
array<string|int, string> —setCachedValue()
Set a value into the cache.
protected
setCachedValue(string $value) : mixed
Parameters
- $value : string
Return values
mixed —setFieldName()
Set the name of this Header field.
protected
setFieldName(string $name) : mixed
Parameters
- $name : string
Return values
mixed —tokenNeedsEncoding()
Redefine the encoding requirements for mailboxes.
protected
tokenNeedsEncoding(string $token) : bool
All "specials" must be encoded as the full header value will not be quoted
Parameters
- $token : string
Tags
Return values
bool —toTokens()
Generate a list of all tokens in the final header.
protected
toTokens([string $string = null ]) : array<string|int, mixed>
Parameters
- $string : string = null
-
The string to tokenize
Return values
array<string|int, mixed> —An array of tokens as strings
assertValidAddress()
Throws an Exception if the address passed does not comply with RFC 2822.
private
assertValidAddress(string $address) : mixed
Parameters
- $address : string
Tags
Return values
mixed —createNameAddressStrings()
Return an array of strings conforming the the name-addr spec of RFC 2822.
private
createNameAddressStrings(array<string|int, string> $mailboxes) : array<string|int, string>
Parameters
- $mailboxes : array<string|int, string>
Return values
array<string|int, string> —escapeSpecials()
Escape special characters in a string (convert to quoted-pairs).
private
escapeSpecials(string $token[, array<string|int, string> $include = [] ]) : string
Parameters
- $token : string
- $include : array<string|int, string> = []
-
additional chars to escape
Return values
string —tokensToString()
Takes an array of tokens which appear in the header and turns them into an RFC 2822 compliant string, adding FWSP where needed.
private
tokensToString(array<string|int, string> $tokens) : string
Parameters
- $tokens : array<string|int, string>