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

The Horde_Mime:: class provides methods for dealing with various MIME (see, e.g., RFC 2045-2049; 2183; 2231) standards.


This file contains code adapted from PEAR's Mail_mimeDecode library (v1.5). http://pear.php.net/package/Mail_mime

This code appears in Horde_Mime::decodeParam().

This code was originally released under this license:

LICENSE: This LICENSE is in the BSD license style. Copyright (c) 2002-2003, Richard Heyes richard@phpguru.org Copyright (c) 2003-2006, PEAR pear-group@php.net All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the authors, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


This file contains code adapted from PEAR's PHP_Compat library (v1.6.0a3). http://pear.php.net/package/PHP_Compat

This code appears in Horde_Mime::_uudecode().

This code was originally released under the LGPL 2.1


Copyright 1999-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.

Package: Mime
Category: Horde
License: LGPL 2.1
Author: Chuck Hagenbuch chuck@horde.org
Author: Michael Slusarz slusarz@horde.org
Located at Horde/Mime.php
Methods summary
public static boolean
# is8bit( string $string, string $charset = null )

Determines if a string contains 8-bit (non US-ASCII) characters.

Determines if a string contains 8-bit (non US-ASCII) characters.

Parameters

$string
The string to check.
$charset
<p>The charset of the string. Defaults to US-ASCII.</p>

Returns

boolean
True if string contains non US-ASCII characters.
public static string
# encode( string $text, string $charset )

Encodes a string containing non-ASCII characters according to RFC 2047.

Encodes a string containing non-ASCII characters according to RFC 2047.

Parameters

$text
The text to encode.
$charset
The character set of the text.

Returns

string

The text, encoded only if it contains non-ASCII characters.

public static string
# quotedPrintableEncode( string $text, string $eol = Horde_Mime::EOL, integer $wrap = 76 )

Encodes a line via quoted-printable encoding.

Encodes a line via quoted-printable encoding.

Parameters

$text
The text to encode.
$eol
The EOL sequence to use.
$wrap
Wrap a line at this many characters.

Returns

string
The quoted-printable encoded string.
public static string
# encodeAddress( mixed $addresses, string $charset, string $defserver = null )

Encodes a string containing email addresses according to RFC 2047.

Encodes a string containing email addresses according to RFC 2047.

This differs from encode() because it keeps email addresses legal, only encoding the personal information.

Parameters

$addresses
<p>The email addresses to encode (either a string or an array of addresses).</p>
$charset
The character set of the text.
$defserver
The default domain to append to mailboxes.

Returns

string

The text, encoded only if it contains non-ASCII characters.

Throws

Horde_Mime_Exception
public static string
# decode( string $string, string $to_charset )

Decodes an RFC 2047-encoded string.

Decodes an RFC 2047-encoded string.

Parameters

$string
The text to decode.
$to_charset
<p>The charset that the text should be decoded to.</p>

Returns

string
The decoded text.
public static string
# decodeAddrString( string $string, string $to_charset )

Decodes an RFC 2047-encoded address string.

Decodes an RFC 2047-encoded address string.

Parameters

$string
The text to decode.
$to_charset
<p>The charset that the text should be decoded to.</p>

Returns

string
The decoded text.

Throws

Horde_Mime_Exception
public static array
# encodeParam( string $name, string $val, string $charset, array $opts = array() )

Encodes a MIME parameter string pursuant to RFC 2183 & 2231 (Content-Type and Content-Disposition headers).

Encodes a MIME parameter string pursuant to RFC 2183 & 2231 (Content-Type and Content-Disposition headers).

Parameters

$name
The parameter name.
$val
The parameter value.
$charset
The charset the text should be encoded with.
$opts
Additional options: <pre><span class="php-quote">'escape'</span> - (boolean) <span class="php-keyword1">If</span> <span class="php-keyword1">true</span>, escape param values <span class="php-keyword1">as</span> described in RFC <span class="php-num">2045</span> [Appendix A]. <span class="php-keyword1">DEFAULT</span>: <span class="php-keyword1">false</span> <span class="php-quote">'lang'</span> - (string) The language to <span class="php-keyword1">use</span> when encoding. <span class="php-keyword1">DEFAULT</span>: None specified</pre>

Returns

array
The encoded parameter string.
public static array
# decodeParam( string $type, mixed $data, string $charset )

Decodes a MIME parameter string pursuant to RFC 2183 & 2231 (Content-Type and Content-Disposition headers).

Decodes a MIME parameter string pursuant to RFC 2183 & 2231 (Content-Type and Content-Disposition headers).

Parameters

$type
<p>Either 'Content-Type' or 'Content-Disposition' (case-insensitive).</p>
$data
<p>The text of the header or an array of param name => param values.</p>
$charset
The charset the text should be decoded to.

Returns

array
An array with the following entries:
'params' - (array) The header's parameter values.
'val' - (string) The header's "base" value.
public static
# generateMessageId( )

Generates a Message-ID string conforming to RFC 2822 [3.6.4] and the standards outlined in 'draft-ietf-usefor-message-id-01.txt'.

Generates a Message-ID string conforming to RFC 2822 [3.6.4] and the standards outlined in 'draft-ietf-usefor-message-id-01.txt'.

public static mixed
# mimeIdArithmetic( string $id, string $action, array $options = array() )

Performs MIME ID "arithmetic" on a given ID.

Performs MIME ID "arithmetic" on a given ID.

Parameters

$id
The MIME ID string.
$action
One of the following: <pre><span class="php-quote">'down'</span> - ID of child. Note: down will first traverse to <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">.0&quot;</span> <span class="php-keyword1">if</span> given an ID *NOT* of the form <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">.0&quot;</span>. <span class="php-keyword1">If</span> given an ID of the form <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">.0&quot;</span>, down will traverse to <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">.1&quot;</span>. This behavior can be avoided <span class="php-keyword1">if</span> <span class="php-quote">'norfc822'</span> option is set. <span class="php-quote">'next'</span> - ID of <span class="php-keyword2">next</span> sibling. <span class="php-quote">'prev'</span> - ID of previous sibling. <span class="php-quote">'up'</span> - ID of parent. Note: up will first traverse to <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">.0&quot;</span> <span class="php-keyword1">if</span> given an ID *NOT* of the form <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">.0&quot;</span>. <span class="php-keyword1">If</span> given an ID of the form <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">.0&quot;</span>, down will traverse to <span class="php-quote">&quot;</span><span class="php-var">$id</span><span class="php-quote">&quot;</span>. This behavior can be avoided <span class="php-keyword1">if</span> <span class="php-quote">'norfc822'</span> option is set.</pre>
$options
Additional options: <pre><span class="php-quote">'count'</span> - (integer) How many levels to traverse. <span class="php-keyword1">DEFAULT</span>: <span class="php-num">1</span> <span class="php-quote">'norfc822'</span> - (boolean) Don<span class="php-quote">'t traverse rfc822 sub-levels DEFAULT: false</span></pre>

Returns

mixed

The resulting ID string, or null if that ID can not exist.

public static boolean
# isChild( string $base, string $id )

Determines if a given MIME ID lives underneath a base ID.

Determines if a given MIME ID lives underneath a base ID.

Parameters

$base
The base MIME ID.
$id
The MIME ID to query.

Returns

boolean
Whether $id lives underneath $base.
public static array
# uudecode( string $input )

Scans $input for uuencoded data and converts it to unencoded data.

Scans $input for uuencoded data and converts it to unencoded data.

Parameters

$input
The input data

Returns

array

A list of arrays, with each array corresponding to a file in the input and containing the following keys:

'data' - (string) Unencoded data.
'name' - (string) Filename.
'perms' - (string) Octal permissions.
Constants summary
string EOL

The RFC defined EOL string.

The RFC defined EOL string.

# "\r\n"
Properties summary
public static boolean $brokenRFC2231

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. See: http://lists.horde.org/archives/dev/Week-of-Mon-20040426/014240.html

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. See: http://lists.horde.org/archives/dev/Week-of-Mon-20040426/014240.html

# false
public static boolean $decodeWindows1252

Use windows-1252 charset when decoding ISO-8859-1 data?

Use windows-1252 charset when decoding ISO-8859-1 data?

# false
API documentation generated by ApiGen