PEAR Handbuch | ||
---|---|---|
Zurück | Nach vorne |
Mail_mimeDecode provides functions to process MIME message. It will take the input you give it and decode it into a usable PHP data structure.
string $input - The message to decode.
string $crlf - This specifies the correct line ending to use. Usually either CRLF or just LF. This option can make the difference between this class working and not. You're strongly recommended to ensure you're email uses exclusively what this argument is set to. Default is CRLF.
This function performs the decoding and returns a structure containing the message data.
array $args -
boolean $args['include_bodies'] - Whether to include the bodies in the returned structure.
boolean $args['decode_bodies'] - Whether to decode the returned bodies.
boolean $args['decode_headers'] - Whether to decode the headers (RFC2047 ).
string $args['input'] - If and only if called statically, this should be used to specify the input to be decoded.
string $args['crlf'] - If and only if called statically, this should be used to specify the line ending type.
array -
array $return['headers'] - An associative array of the headers. The keys of the array are the header names (lowercased) whilst the values are the header values (original case). if there are multiple headers with the same name (eg. Recieved: ) then the value is a numerically indexed array of each of the header values. If the parameter decode_headers is specified as true, then the headers will be decoded (RFC2047).
string $return['ctype_primary'] - The first part of the content type (ie. before the forward slash). Eg. If the content type is multipart/mixed, ctype_primary would be "multipart".
string $return['ctype_secondary'] - The second part of the content type. Eg. If the content type is multipart/mixed, ctype_secondary would be "mixed".
array $return['ctype_parameter'] - If the content type header has any parameters (eg. boundary="=_hudfhdsalfhds8fy8329hfj") then they will be in this associative array. Keys are the parameter name (eg. boundary) whilst the values are the parameter values (eg. =_hudfhdsalfhds8fy8329hfj).
string $return['disposition'] - If the Content-Disposition header is present, it's value will be given here. This is usually either "inline" or "attachment".
array $return['d_parameters'] - If any parameters are given with the Content-Disposition header, they will be given here in an associative array, keys being the parameter names and values being the parameter values. "name" and "filename" are two common examples here.
array $return['d_parameters'] - If any parameters are given with the Content-Disposition header, they will be given here in an associative array, keys being the parameter names and values being the parameter values. "name" and "filename" are two common examples here.
array $return['body'] - If the include_bodies parameter is given when instanciating the class, (either statically or normally), then this will be present if the part in question has a body. MIME parts with content type multipart/* generally do not not have bodies, instead consisting of subparts. If the parameter decode_bodies is specified as true then the body will be decoded.
array $return['parts'] - If a MIME part consists of subparts, then this array will be present consisting of objects with the same properties as described here.
uudecode() looks for UU-encoded parts in the given message. UU stands for the Unix-to-Unix protocol. Actually this is a common used protocoll for transfering files using the 7-bit-ASCII character set over the internet.
array - An array of associative arrays
string $return[]['filename'] - The name of the UUencoded file.
string $return[]['fileperm'] - The file permissions of the UUencoded file, if given. The format is unix-styled, ie. "0666" or "666".
string $return[]['filedata'] - The decoded content of the UUencoded file.
getXML() converts the returned array from decode () into a valid XML document. The DTD for this document is avaible from the Mail_MimeDecode-Package or http://www.phpguru.org/xmail/ .
<?php include 'Mail/mimeDecode.php'; ... $params['include_bodies'] = TRUE; $params['decode_bodies'] = TRUE; $params['decode_headers'] = TRUE; $decoder = new Mail_mimeDecode($input); $structure = $decoder->decode($params); ?> |
This example calls the decode function statically (ie no object, straight function call) and then passes the structure to the getXML() function.
<?php ... $params['include_bodies'] = TRUE; $params['decode_bodies'] = FALSE; $params['decode_headers'] = TRUE; $params['input'] = $input; $params['crlf'] = "\r\n"; $structure = Mail_mimeDecode::decode($params); $xml = Mail_mimeDecode::getXML($structure); ?> |
Zurück | Zum Anfang | Nach vorne |
Mail_mimePart | Nach oben | Mail_RFC822 |