Class MIME

Description

The MIME:: class provides methods for dealing with MIME standards.

$Horde: framework/MIME/MIME.php,v 1.139.4.50 2010-09-13 18:38:29 slusarz Exp $

Copyright 1999-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /MIME/MIME.php (line 61)


	
			
Variable Summary
Method Summary
 string addrArray2String (array $addresses, [mixed $filter = ''])
 string addrObject2String (stdClass $ob, [mixed $filter = ''])
 mixed bareAddress (string $address, [string $defserver = null], [boolean $multiple = false])
 string decode (string $string, [string $to_charset = null])
 string decodeAddrString (string $string, [string $to_charset = null])
 array decodeRFC2231 (string $string, [string $to_charset = null])
 string encode (string $text, [string $charset = null])
 string encodeAddress (string $addresses, [string $charset = null], [string $defserver = null])
 array encodeRFC2231 (string $name, string $string, string $charset, [string $lang = null])
 mixed encoding (mixed $input, [integer $format = null])
 void generateMessageID (string 0)
 boolean is8bit (string $string, [string $charset = null])
 array parseAddressList (string $address, [string $defserver = null], [boolean $validate = false])
 string quotedPrintableEncode (string $text, string $eol)
 array rfc822Explode (string $string, [string $delimiters = ','])
 string rfc822WriteAddress (string $mailbox, [string $host = null], [string $personal = ''])
 string trimEmailAddress (string $address)
 mixed type (mixed $input, [integer $format = null])
 string wrapHeaders (string $header, string $text, [string $eol = "\r\n"])
Variables
array $mime_encodings = array(
ENC7BIT => '7bit',
ENC8BIT => '8bit',
ENCBINARY => 'binary',
ENCBASE64 => 'base64',
ENCQUOTEDPRINTABLE => 'quoted-printable',
ENCOTHER => 'unknown'
)
(line 85)

A listing of the allowed MIME encodings.

array $mime_types = array(
TYPETEXT => 'text',
TYPEMULTIPART => 'multipart',
TYPEMESSAGE => 'message',
TYPEAPPLICATION => 'application',
TYPEAUDIO => 'audio',
TYPEIMAGE => 'image',
TYPEVIDEO => 'video',
TYPEMODEL => 'model',
TYPEOTHER => 'other'
)
(line 68)

A listing of the allowed MIME types.

string $rfc822_filter = "()<>@,;:\\\"[]\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177" (line 99)

Filter for RFC822.

Methods
addrArray2String (line 705)

Takes an array of address objects, as returned by imap_headerinfo(), for example, and passes each of them through MIME::addrObject2String().

  • return: All of the addresses in a comma-delimited string. Returns the empty string on error/no addresses found.
string addrArray2String (array $addresses, [mixed $filter = ''])
  • array $addresses: The array of address objects.
  • mixed $filter: A user@example.com style bare address to ignore. If any address matches $filter, it will not be included in the final string.
addrObject2String (line 654)

Takes an address object, as returned by imap_header() for example, and formats it as a string.

Object format for the address "John Doe <john_doe@example.com>" is:

   $object->personal = Personal name ("John Doe")
   $object->mailbox  = The user's mailbox ("john_doe")
   $object->host     = The host the mailbox is on ("example.com")

  • return: The formatted address (Example: John Doe <john_doe@example.com>).
string addrObject2String (stdClass $ob, [mixed $filter = ''])
  • stdClass $ob: The address object to be turned into a string.
  • mixed $filter: A user@example.com style bare address to ignore. Either single string or an array of strings. If the address matches $filter, an empty string will be returned.
bareAddress (line 741)

Returns the bare address.

  • return: If $multiple is false, returns the mailbox@host e-mail address. If $multiple is true, returns an array of these addresses.
mixed bareAddress (string $address, [string $defserver = null], [boolean $multiple = false])
  • string $address: The address string.
  • string $defserver: The default domain to append to mailboxes.
  • boolean $multiple: Should we return multiple results?
decode (line 319)

Decodes an RFC 2047-encoded string.

  • return: The decoded text.
string decode (string $string, [string $to_charset = null])
  • string $string: The text to decode.
  • string $to_charset: The charset that the text should be decoded to.
decodeAddrString (line 392)

Decodes an RFC 2047-encoded address string.

  • return: The decoded text.
string decodeAddrString (string $string, [string $to_charset = null])
  • string $string: The text to decode.
  • string $to_charset: The charset that the text should be decoded to.
decodeRFC2231 (line 470)

Decodes an RFC 2231-encoded string.

  • return: The decoded text, or the original string if it was not encoded.
array decodeRFC2231 (string $string, [string $to_charset = null])
  • string $string: The entire string to decode, including the parameter name.
  • string $to_charset: The charset the text should be decoded to.
encode (line 129)

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

  • return: The text, encoded only if it contains non-ASCII characters.
string encode (string $text, [string $charset = null])
  • string $text: The text to encode.
  • string $charset: The character set of the text.
encodeAddress (line 267)

Encodes a string containing email addresses according to RFC 2047.

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

  • return: The text, encoded only if it contains non-ascii characters, or PEAR_Error on error.
string encodeAddress (string $addresses, [string $charset = null], [string $defserver = null])
  • string $addresses: The email addresses to encode.
  • string $charset: The character set of the text.
  • string $defserver: The default domain to append to mailboxes.
encodeRFC2231 (line 413)

Encodes a string pursuant to RFC 2231.

  • return: The encoded parameter string.
array encodeRFC2231 (string $name, string $string, string $charset, [string $lang = null])
  • string $name: The parameter name.
  • string $string: The string to encode.
  • string $charset: The charset the text should be encoded with.
  • string $lang: The language to use when encoding.
encoding (line 877)

Returns the MIME encoding for the given input.

  • return: See above.
mixed encoding (mixed $input, [integer $format = null])
  • mixed $input: Either the MIME code or encoding string.
  • integer $format: If MIME_CODE, return code. If MIME_STRING, returns lowercase string. If not set, returns the opposite value.
generateMessageID (line 933)

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

void generateMessageID (string 0)
  • string 0: A message ID string.
is8bit (line 110)

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

  • return: True if it does, false if it doesn't.
boolean is8bit (string $string, [string $charset = null])
  • string $string: The string to check.
  • string $charset: The charset of the string. Defaults to US-ASCII. Since Horde 3.2.2.
parseAddressList (line 781)

Parses a list of email addresses into its parts.

Works with and without the imap extension being available and parses distribution lists as well.

array parseAddressList (string $address, [string $defserver = null], [boolean $validate = false])
  • string $address: The address string.
  • string $defserver: The default domain to append to mailboxes.
  • boolean $validate: Whether to validate the address(es).
quotedPrintableEncode (line 209)

Encodes a line via quoted-printable encoding.

Wraps lines at 76 characters.

  • return: The quoted-printable encoded string.
string quotedPrintableEncode (string $text, string $eol)
  • string $text: The text to encode.
  • string $eol: The EOL sequence to use.
rfc822Explode (line 581)

Explodes an RFC 2822 string, ignoring a delimiter if preceded by a "\" character, or if the delimiter is inside single or double quotes.

  • return: The exploded string in an array.
array rfc822Explode (string $string, [string $delimiters = ','])
  • string $string: The RFC 822 string.
  • string $delimiters: A string containing valid delimiters. Defaults to ','.
rfc822WriteAddress (line 547)

Builds an RFC 822 compliant email address.

  • return: The correctly escaped and quoted "$personal <$mailbox@$host>" string.
string rfc822WriteAddress (string $mailbox, [string $host = null], [string $personal = ''])
  • string $mailbox: Mailbox name.
  • string $host: Domain name of mailbox's host.
  • string $personal: Personal name phrase.
trimEmailAddress (line 526)

If an email address has no personal information, get rid of any angle brackets (<>) around it.

  • return: The trimmed address.
string trimEmailAddress (string $address)
  • string $address: The address to trim.
type (line 862)

Returns the MIME type for the given input.

  • return: See above.
mixed type (mixed $input, [integer $format = null])
  • mixed $input: Either the MIME code or type string.
  • integer $format: If MIME_CODE, return code. If MIME_STRING, returns lowercase string.
wrapHeaders (line 951)

Adds proper linebreaks to a header string.

RFC 2822 says headers SHOULD only be 78 characters a line, but also says that a header line MUST not be more than 998 characters.

  • return: The header text, with linebreaks inserted.
string wrapHeaders (string $header, string $text, [string $eol = "\r\n"])
  • string $header: The header name.
  • string $text: The text of the header field.
  • string $eol: The EOL string to use.

Documentation generated on Sun, 30 Jan 2011 05:19:38 +0000 by phpDocumentor 1.4.3