Overview

Packages

  • Mime

Classes

  • Horde_Mime
  • Horde_Mime_Address
  • Horde_Mime_Exception
  • Horde_Mime_Headers
  • Horde_Mime_Magic
  • Horde_Mime_Mail
  • Horde_Mime_Mdn
  • Horde_Mime_Part
  • Horde_Mime_Translation
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Mime_Headers

This class contains functions related to handling the headers of MIME data.

Copyright 2002-2012 Horde LLC (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Horde_Mime_Headers implements Serializable
Package: Mime
Category: Horde
License: LGPL 2.1
Author: Michael Slusarz slusarz@horde.org
Located at Horde/Mime/Headers.php
Methods summary
public array
# toArray( array $options = array() )

Returns the internal header array in array format.

Returns the internal header array in array format.

Parameters

$options
<p>Optional parameters: - canonical: (boolean) Use canonical (RFC 822/2045) line endings? DEFAULT: Uses $this->_eol - charset: (string) Encodes the headers using this charset. If empty, encodes using internal charset (UTF-8). DEFAULT: No encoding. - defserver: (string) The default domain to append to mailboxes. DEFAULT: No default name. - nowrap: (integer) Don't wrap the headers. DEFAULT: Headers are wrapped.</p>

Returns

array
The headers in array format.
public string
# toString( array $options = array() )

Returns the internal header array in string format.

Returns the internal header array in string format.

Parameters

$options
<p>Optional parameters: - canonical: (boolean) Use canonical (RFC 822/2045) line endings? DEFAULT: Uses $this->_eol - charset: (string) Encodes the headers using this charset. DEFAULT: No encoding. - defserver: (string) The default domain to append to mailboxes. DEFAULT: No default name. - nowrap: (integer) Don't wrap the headers. DEFAULT: Headers are wrapped.</p>

Returns

string
The headers in string format.
public
# addReceivedHeader( array $options = array() )

Generate the 'Received' header for the Web browser->Horde hop (attempts to conform to guidelines in RFC 5321 [4.4]).

Generate the 'Received' header for the Web browser->Horde hop (attempts to conform to guidelines in RFC 5321 [4.4]).

Parameters

$options
<p>Additional options: - dns: (Net_DNS2_Resolver) Use the DNS resolver object to lookup hostnames. DEFAULT: Use gethostbyaddr() function. - server: (string) Use this server name. DEFAULT: Auto-detect using current PHP values.</p>
public
# addMessageIdHeader( )

Generate the 'Message-ID' header.

Generate the 'Message-ID' header.

public
# addUserAgentHeader( )

Generate the user agent description header.

Generate the user agent description header.

public string
# getUserAgent( )

Returns the user agent description header.

Returns the user agent description header.

Returns

string
The user agent header.
public
# setUserAgent( string $agent )

Explicitly sets the User-Agent string.

Explicitly sets the User-Agent string.

Parameters

$agent
The User-Agent string to use.
public
# addHeader( string $header, string $value, array $options = array() )

Add a header to the header array.

Add a header to the header array.

Parameters

$header
The header name.
$value
The header value.
$options
<p>Additional options: - charset: (string) Charset of the header value. DEFAULT: UTF-8 - decode: (boolean) MIME decode the value? DEFAULT: false - params: (array) MIME parameters for Content-Type or Content-Disposition. DEFAULT: None</p>
public
# removeHeader( string $header )

Remove a header from the header array.

Remove a header from the header array.

Parameters

$header
The header name.
public
# replaceHeader( string $header, string $value, array $options = array() )

Replace a value of a header.

Replace a value of a header.

Parameters

$header
The header name.
$value
The header value.
$options
<p>Additional options: - charset: (string) Charset of the header value. DEFAULT: UTF-8 - decode: (boolean) MIME decode the value? DEFAULT: false - params: (array) MIME parameters for Content-Type or Content-Disposition. DEFAULT: None</p>
public boolean
# setValue( string $header, string $value, array $options = array() )

Set a value for a particular header ONLY if that header is set.

Set a value for a particular header ONLY if that header is set.

Parameters

$header
The header name.
$value
The header value.
$options
<p>Additional options: - charset: (string) Charset of the header value. DEFAULT: UTF-8 - decode: (boolean) MIME decode the value? - params: (array) MIME parameters for Content-Type or Content-Disposition.</p>

Returns

boolean
True if value was set.
public string
# getString( string $header )

Attempts to return the header in the correct case.

Attempts to return the header in the correct case.

Parameters

$header
The header to search for.

Returns

string

The value for the given header. If the header is not found, returns null.

public mixed
# getValue( string $header, integer $type = Horde_Mime_Headers::VALUE_STRING )

Attempt to return the value for a given header. The following header fields can only have 1 entry, so if duplicate entries exist, the first value will be used: * To, From, Cc, Bcc, Date, Sender, Reply-to, Message-ID, In-Reply-To, References, Subject (RFC 2822 [3.6]) * All List Headers (RFC 2369 [3]) The values are not MIME encoded.

Attempt to return the value for a given header. The following header fields can only have 1 entry, so if duplicate entries exist, the first value will be used: * To, From, Cc, Bcc, Date, Sender, Reply-to, Message-ID, In-Reply-To, References, Subject (RFC 2822 [3.6]) * All List Headers (RFC 2369 [3]) The values are not MIME encoded.

Parameters

$header
The header to search for.
$type
<p>The type of return: - VALUE_STRING: Returns a string representation of the entire header. - VALUE_BASE: Returns a string representation of the base value of the header. If this is not a header that allows parameters, this will be equivalent to VALUE_STRING. - VALUE_PARAMS: Returns the list of parameters for this header. If this is not a header that allows parameters, this will be an empty array.</p>

Returns

mixed

The value for the given header. If the header is not found, returns null.

public static array
# addressFields( )

Returns the list of RFC defined header fields that contain address info.

Returns the list of RFC defined header fields that contain address info.

Returns

array
The list of headers, in lowercase.
public array
# singleFields( boolean $list = true )

Returns the list of RFC defined header fields that can only contain a single value.

Returns the list of RFC defined header fields that can only contain a single value.

Parameters

$list
Return list-related headers also?

Returns

array
The list of headers, in lowercase.
public static array
# mimeParamFields( )

Returns the list of RFC defined MIME header fields that may contain parameter info.

Returns the list of RFC defined MIME header fields that may contain parameter info.

Returns

array
The list of headers, in lowercase.
public static array
# listHeaders( )

Returns the list of valid mailing list headers.

Returns the list of valid mailing list headers.

Returns

array
The list of valid mailing list headers.
public boolean
# listHeadersExist( )

Do any mailing list headers exist?

Do any mailing list headers exist?

Returns

boolean
True if any mailing list headers exist.
public
# setEOL( string $eol )

Sets a new string to use for EOLs.

Sets a new string to use for EOLs.

Parameters

$eol
The string to use for EOLs.
public string
# getEOL( )

Get the string to use for EOLs.

Get the string to use for EOLs.

Returns

string
The string to use for EOLs.
public array
# getOb( string $field )

Returns a header from the header object.

Returns a header from the header object.

Parameters

$field
The header to return as an object.

Returns

array
The object for the field requested.

See

Horde_Mime_Address::parseAddressList()
public static Horde_Mime_Headers
# parseHeaders( string $text )

Builds a Horde_Mime_Headers object from header text. This function can be called statically: $headers = Horde_Mime_Headers::parseHeaders().

Builds a Horde_Mime_Headers object from header text. This function can be called statically: $headers = Horde_Mime_Headers::parseHeaders().

Parameters

$text
A text string containing the headers.

Returns

Horde_Mime_Headers
A new Horde_Mime_Headers object.
public static string
# sanityCheck( string $header, string $data, array $opts = array() )

Perform sanity checking on a raw header (e.g. handle 8-bit characters). This function can be called statically: $headers = Horde_Mime_Headers::sanityCheck().

Perform sanity checking on a raw header (e.g. handle 8-bit characters). This function can be called statically: $headers = Horde_Mime_Headers::sanityCheck().

Parameters

$header
The header.
$data
The header data.
$opts
<p>Optional parameters: - encode: (boolean) If true, will MIME encode any 8-bit characters. If false (default), converts the text to UTF-8.</p>

Returns

string
The cleaned header data.

Since

Horde_Mime 1.4.0
public string
# serialize( )

Serialization.

Serialization.

Returns

string
Serialized data.

Implementation of

Serializable::serialize()
public
# unserialize( string $data )

Unserialization.

Unserialization.

Parameters

$data
Serialized data.

Throws

Exception

Implementation of

Serializable::unserialize()
Constants summary
integer VERSION
# 1
integer VALUE_STRING
# 1
integer VALUE_BASE
# 2
integer VALUE_PARAMS
# 3
Properties summary
public static string $defaultCharset

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

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

# 'us-ascii'
API documentation generated by ApiGen