\Horde_Mime_Headers

This class represents the collection of header values for a single mail message part.

It supports the base e-mail spec (RFC 5322) and the MIME extensions to that spec (RFC 2045).

Summary

Methods
Properties
Constants
__construct()
__clone()
toArray()
toString()
addHeader()
addHeaderOb()
getHeader()
removeHeader()
parseHeaders()
serialize()
unserialize()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
getIterator()
__call()
__callStatic()
setEOL()
getEOL()
$defaultCharset
VERSION
VALUE_STRING
VALUE_BASE
VALUE_PARAMS
_getHeaderClassName()
$_handlers
$_headers
$_eol
N/A
No private methods found
No private properties found
N/A

Constants

VERSION

VERSION

VALUE_STRING

VALUE_STRING

VALUE_BASE

VALUE_BASE

VALUE_PARAMS

VALUE_PARAMS

Properties

$defaultCharset

$defaultCharset : string

The default charset to use when parsing text parts with no charset information.

Type

string

$_handlers

$_handlers : array

Cached handler information for Header Element objects.

Type

array

$_headers

$_headers : \Horde_Support_CaseInsensitiveArray

The internal headers array.

Type

\Horde_Support_CaseInsensitiveArray

$_eol

$_eol : 

Type

Methods

__construct()

__construct() 

Constructor.

__clone()

__clone() 

toArray()

toArray(array  $opts = array()) : array

Returns the headers in array format.

Parameters

array $opts

Optional parameters:

  - broken_rfc2231: (boolean) Attempt to work around non-RFC
                    2231-compliant MUAs by generating both a RFC
                    2047-like parameter name and also the correct RFC
                    2231 parameter
                    DEFAULT: false
  - canonical: (boolean) Use canonical (RFC 822/2045) CRLF EOLs?
               DEFAULT: Uses "\n"
  - charset: (string) Encodes the headers using this charset. If empty,
             encodes using UTF-8.
             DEFAULT: No encoding.
  - defserver: (string) The default domain to append to mailboxes.
               DEFAULT: No default name.
  - lang: (string) The language to use when encoding.
          DEFAULT: None specified
  - nowrap: (integer) Don't wrap the headers.
            DEFAULT: Headers are wrapped.

Returns

array —

The headers in array format. Keys are header names, but case sensitivity cannot be guaranteed. Values are header values.

toString()

toString(array  $opts = array()) : string

Returns all headers concatenated into a single string.

Parameters

array $opts

See toArray().

Returns

string —

The headers in string format.

addHeader()

addHeader(string  $header, string  $value, array  $opts = array()) 

Add/append/replace a header.

Parameters

string $header

The header name.

string $value

The header value (UTF-8).

array $opts

DEPRECATED

addHeaderOb()

addHeaderOb(\Horde_Mime_Headers_Element  $ob, boolean  $check = false) 

Add a Horde_Mime_Headers_Element object to the current header list.

Parameters

\Horde_Mime_Headers_Element $ob

Header object to add.

boolean $check

Check that the header and object type match?

Throws

\InvalidArgumentException

getHeader()

getHeader(string  $header) : \Horde_Mime_Headers_Element

Get a header from the header array.

Parameters

string $header

The header name.

Returns

\Horde_Mime_Headers_Element

Element object, or null if not found.

removeHeader()

removeHeader(string  $header) 

Remove a header from the header array.

Parameters

string $header

The header name.

parseHeaders()

parseHeaders(mixed  $text) : \Horde_Mime_Headers

Builds a Horde_Mime_Headers object from header text.

Parameters

mixed $text

A text string (or, as of 2.3.0, a Horde_Stream object or stream resource) containing the headers.

Returns

\Horde_Mime_Headers

A new Horde_Mime_Headers object.

serialize()

serialize() : string

Serialization.

Returns

string —

Serialized data.

unserialize()

unserialize(string  $data) 

Unserialization.

Parameters

string $data

Serialized data.

Throws

\Exception

offsetExists()

offsetExists(  $offset) : boolean

Does header exist?

Parameters

$offset

Returns

boolean —

True if header exists.

offsetGet()

offsetGet(  $offset) : \Horde_Mime_Headers_Element

Return header element object.

Parameters

$offset

Returns

\Horde_Mime_Headers_Element

Element object, or null if not found.

offsetSet()

offsetSet(string  $offset,   $value) 

Store a header element object.

Parameters

string $offset

Not used.

$value

offsetUnset()

offsetUnset(string  $offset) 

Remove a header element object.

Parameters

string $offset

Header name.

getIterator()

getIterator() 

__call()

__call(  $name,   $arguments) 

Handle deprecated methods.

Parameters

$name
$arguments

__callStatic()

__callStatic(  $name,   $arguments) 

Handle deprecated static methods.

Parameters

$name
$arguments

setEOL()

setEOL(  $eol) 

Parameters

$eol

getEOL()

getEOL() 

_getHeaderClassName()

_getHeaderClassName(string  $header) : string

Return the header class to use for a header name.

Parameters

string $header

The header name.

Returns

string —

The Horde_MimeHeaders* class to use.