Basic mail headers collection functionality

Handles aggregation of headers

package Default

 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

Parameters

$header

\Zend\Mail\Header\HeaderInterface

Returns

\Zend\Mail\Headers

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

addHeaderLine(string $headerFieldNameOrLine, string $fieldValue = null) : \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

\Zend\Mail\Headers

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

\Zend\Mail\Headers

Clear all headers

clearHeaders() : \Zend\Mail\Headers

Removes all headers from queue

Returns

\Zend\Mail\Headers

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. If you need an exact count, iterate

count() : integer

Returns

integercount of currently known headers

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

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

Returns

\Zend\Mail\Header\HeaderInterface

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

forceLoading() : boolean

Returns

boolean

Populates headers from string representation

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

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

\Zend\Mail\Headers

Get all headers of a certain name/type

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

Parameters

$name

string

Returns

boolean\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

Returns

\Zend\Loader\PluginClassLocator

Test for existence of a type of header

has(string $name) : boolean

Parameters

$name

string

Returns

boolean

Return the current key for this object as an iterator

key() : mixed

Returns

mixed

Advance the pointer for this object as an iterator

next() 

Remove a Header from the container

removeHeader($instanceOrFieldName) : boolean

Parameters

$instanceOrFieldName

Returns

boolean

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

\Zend\Mail\Headers

Set an alternate implementation for the PluginClassLoader

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

Parameters

$pluginClassLoader

\Zend\Loader\PluginClassLocator

Returns

\Zend\Mail\Headers

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() : boolean

Returns

boolean

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

Default

'ASCII'
 

instances

$headers : array<mixed,\Zend\Mail\Header\HeaderInterface>

Default

array()
 

key names for $headers array

$headersKeys : array

Default

array()
 

$pluginClassLoader

$pluginClassLoader : \Zend\Loader\PluginClassLoader

Default

null

 Constants

 

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

EOL = "\r\n" : string
 

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

FOLDING = "\r\n " : string