[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Pear/Mail/ -> mimeDecode.php (sommaire)

(pas de description)

Poids: 837 lignes (31 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

Mail_mimeDecode:: (16 méthodes):
  Mail_mimeDecode()
  decode()
  _decode()
  getMimeNumbers()
  _splitBodyHeader()
  _parseHeaders()
  _parseHeaderValue()
  _boundarySplit()
  _decodeHeader()
  _decodeBody()
  _quotedPrintableDecode()
  uudecode()
  getSendArray()
  getXML()
  _getXML()
  _getXML_helper()


Classe: Mail_mimeDecode  - X-Ref

+----------------------------- IMPORTANT ------------------------------+
| Usage of this class compared to native php extensions such as        |
| mailparse or imap, is slow and may be feature deficient. If available|
| you are STRONGLY recommended to use the php extensions.              |
+----------------------------------------------------------------------+

Mime Decoding class

This class will parse a raw mime email and return
the structure. Returned structure is similar to
that returned by imap_fetchstructure().

USAGE: (assume $input is your raw email)

$decode = new Mail_mimeDecode($input, "\r\n");
$structure = $decode->decode();
print_r($structure);

Or statically:

$params['input'] = $input;
$structure = Mail_mimeDecode::decode($params);
print_r($structure);

TODO:
o Implement multipart/appledouble
o UTF8: ???

Mail_mimeDecode($input)   X-Ref
Constructor.

Sets up the object, initialise the variables, and splits and
stores the header and body of the input.

param: string The input to decode

decode($params = null)   X-Ref
Begins the decoding process. If called statically
it will create an object and call the decode() method
of it.

param: array An array of various parameters that determine
return: object Decoded results

_decode($headers, $body, $default_ctype = 'text/plain')   X-Ref
Performs the decoding. Decodes the body string passed to it
If it finds certain content-types it will call itself in a
recursive fashion

param: string Header section
param: string Body section
return: object Results of decoding process

getMimeNumbers(&$structure, $no_refs = false, $mime_number = '', $prepend = '')   X-Ref
Given the output of the above function, this will return an
array of references to the parts, indexed by mime number.

param: object $structure   The structure to go through
param: string $mime_number Internal use only.
return: array               Mime numbers

_splitBodyHeader($input)   X-Ref
Given a string containing a header and body
section, this function will split them (at the first
blank line) and return them.

param: string Input to split apart
return: array Contains header and body section

_parseHeaders($input)   X-Ref
Parse headers given in $input and return
as assoc array.

param: string Headers to parse
return: array Contains parsed headers

_parseHeaderValue($input)   X-Ref
Function to parse a header value,
extract first part, and any secondary
parts (after ;) This function is not as
robust as it could be. Eg. header comments
in the wrong place will probably break it.

param: string Header value to parse
return: array Contains parsed result

_boundarySplit($input, $boundary)   X-Ref
This function splits the input based
on the given boundary

param: string Input to parse
return: array Contains array of resulting mime parts

_decodeHeader($input)   X-Ref
Given a header, this function will decode it
according to RFC2047. Probably not *exactly*
conformant, but it does pass all the given
examples (in RFC2047).

param: string Input header value to decode
return: string Decoded header value

_decodeBody($input, $encoding = '7bit')   X-Ref
Given a body string and an encoding type,
this function will decode and return it.

param: string Input body to decode
param: string Encoding type to use.
return: string Decoded body

_quotedPrintableDecode($input)   X-Ref
Given a quoted-printable string, this
function will decode and return it.

param: string Input body to decode
return: string Decoded body

uudecode($input)   X-Ref
Checks the input for uuencoded files and returns
an array of them. Can be called statically, eg:

$files =& Mail_mimeDecode::uudecode($some_text);

It will check for the begin 666 ... end syntax
however and won't just blindly decode whatever you
pass it.

author: Unknown
param: string Input body to look for attahcments in
return: array  Decoded bodies, filenames and permissions

getSendArray()   X-Ref
getSendArray() returns the arguments required for Mail::send()
used to build the arguments for a mail::send() call

Usage:
$mailtext = Full email (for example generated by a template)
$decoder = new Mail_mimeDecode($mailtext);
$parts =  $decoder->getSendArray();
if (!PEAR::isError($parts) {
list($recipents,$headers,$body) = $parts;
$mail = Mail::factory('smtp');
$mail->send($recipents,$headers,$body);
} else {
echo $parts->message;
}
author: Alan Knowles <alan@akbkhome.com>
return: mixed   array of recipeint, headers,body or Pear_Error

getXML($input)   X-Ref
Returns a xml copy of the output of
Mail_mimeDecode::decode. Pass the output in as the
argument. This function can be called statically. Eg:

$output = $obj->decode();
$xml    = Mail_mimeDecode::getXML($output);

The DTD used for this should have been in the package. Or
alternatively you can get it from cvs, or here:
http://www.phpguru.org/xmail/xmail.dtd.

param: object Input to convert to xml. This should be the
return: string XML version of input

_getXML($input, $indent = 1)   X-Ref
Function that does the actual conversion to xml. Does a single
mimepart at a time.

param: object  Input to convert to xml. This is a mimepart object.
param: integer Number of tabs to indent
return: string  XML version of input

_getXML_helper($hdr_name, $hdr_value, $indent)   X-Ref
Helper function to _getXML(). Returns xml of a header.

param: string  Name of header
param: string  Value of header
param: integer Number of tabs to indent
return: string  XML version of input



Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7