Basic mail headers collection functionality

Handles aggregation of headers

 Methods

Add a Header\Interface to this container, for raw values see {@link addHeaderLine()} and {@link addHeaders()}

addHeader(\Zend\Mail\Header\HeaderInterface $header) : \Zend\Mail\Headers

Add a raw header line, either in name => value, or as a single string 'name: value'

addHeaderLine(string $headerFieldNameOrLine, string $fieldValue) : \Zend\Mail\Headers

This method allows for lazy-loading in that the parsing and instantiation of HeaderInterface object will be delayed until they are retrieved by either get() or current()

Parameters

$headerFieldNameOrLine

string

$fieldValue

string

optional

Exceptions

\Zend\Mail\Exception\InvalidArgumentException

Returns

Add many headers at once

addHeaders(array | \Traversable $headers) : \Zend\Mail\Headers

Expects an array (or Traversable object) of type/value pairs.

Parameters

$headers

array\Traversable

Exceptions

\Zend\Mail\Exception\InvalidArgumentException

Returns

Clear all headers

clearHeaders() : \Zend\Mail\Headers

Removes all headers from queue

Returns

Return the number of headers in this contain, if all headers have not been parsed, actual count could increase if MultipleHeader objects exist in the Request/Response.

count() : int

If you need an exact count, iterate

Returns

intcount of currently known headers

Return the current value for this iterator, lazy loading it if need be

current() : \Zend\Mail\Header\HeaderInterface

By calling this, it will force parsing and loading of all headers, after this count() will be accurate

forceLoading() : bool

Returns

bool

Populates headers from string representation

fromString(string $string, string $EOL) : \Zend\Mail\Headers

Parses a string for headers, and aggregates them, in order, in the current instance, primarily as strings until they are needed (they will be lazy loaded)

Parameters

$string

string

$EOL

string

EOL string; defaults to {@link EOL}

Exceptions

\Zend\Mail\Exception\RuntimeException

Returns

Get all headers of a certain name/type

get(string $name) : bool | \ArrayIterator | \Zend\Mail\Header\HeaderInterface

Parameters

$name

string

Returns

bool\ArrayIterator\Zend\Mail\Header\HeaderInterfaceReturns false if there is no headers with $name in this contain, an ArrayIterator if the header is a MultipleHeadersInterface instance and finally returns HeaderInterface for the rest of cases.

Get the header encoding

getEncoding() : string

Returns

string

Return an instance of a PluginClassLocator, lazyload and inject map if necessary

getPluginClassLoader() : \Zend\Loader\PluginClassLocator

Test for existence of a type of header

has(string $name) : bool

Parameters

$name

string

Returns

bool

Return the current key for this object as an iterator

key() : mixed

Returns

mixed

Remove a Header from the container

removeHeader(string $fieldName) : bool

Parameters

$fieldName

string

Returns

bool

Reset the internal pointer for this object as an iterator

rewind() 

Set the header encoding

setEncoding(string $encoding) : \Zend\Mail\Headers

Parameters

$encoding

string

Returns

Set an alternate implementation for the PluginClassLoader

setPluginClassLoader(\Zend\Loader\PluginClassLocator $pluginClassLoader) : \Zend\Mail\Headers

Parameters

$pluginClassLoader

\Zend\Loader\PluginClassLocator

Returns

Return the headers container as an array

toArray() : array

todo determine how to produce single line headers, if they are supported

Returns

array

Render all headers at once

toString() : string

This method handles the normal iteration of headers; it is up to the concrete classes to prepend with the appropriate status/request line.

Returns

string

Is this iterator still valid?

valid() : bool

Returns

bool

lazyLoadHeader()

lazyLoadHeader($index) : mixed

Parameters

$index

Returns

mixed

Normalize a field name

normalizeFieldName(string $fieldName) : string

Parameters

$fieldName

string

Returns

string

 Properties

 

Header encoding; defaults to ASCII

$encoding : string

 

<p>instances</p>

$headers : \Zend\Mail\Header\HeaderInterface[]

 

<p>key names for $headers array</p>

$headersKeys : array

 

$pluginClassLoader

$pluginClassLoader : \Zend\Loader\PluginClassLoader

 Constants

 

<p>End of Line for fields</p>

EOL : string

 

<p>Start of Line when folding</p>

FOLDING : string