Searches $structure property set in Mail_IMAP::_declareParts for a displayable message. If the part id passed is message/rfc822 (an attached email message) getBody automatically looks in subparts for a displayable body.
Attempts to return a text/html inline message part by default. And will automatically attempt to find a text/plain part if a text/html part could not be found. This can be reversed to find a text/plain part by default and a text/html part if a text/plain part couldn"t be found by specifying the default MIME type in the $get_mime argument. The $attempt argument is used internally to track the method"s attempt at finding a suitable message part to display.
By default getBody returns an array containing four associative indices; "ftype", "fname", "charset" and "message". "ftype" contains the MIME type of the message, "fname", the original file name, if any (empty string otherwise), "charset" contains information about the character set and "message", contains the message body itself, which is returned decoded from base64 or quoted-printable if either of those encoding types are specified, returns untouched otherwise. Returns FALSE on failure.
Internally, getBody calls on two methods, Mail_IMAP::_checkIfParsed (protected) and Mail_IMAP::_scanMultipart (private).
The $action argument of getBody may accept any one of the following constants which toggles how the function returns data.
| Constant | Purpose |
| MAIL_IMAPv2_BODY | (default value) If the message part is message/rfc822 searches subparts for a displayable body and returns the body decoded as part of an array. |
| MAIL_IMAPv2_LITERAL | Return the message part for the specified $part id without searching subparts or decoding the message (may return unparsed message). |
| MAIL_IMAPv2_LITERAL_DECODE | Same as MAIL_IMAP_LITERALv2, except message decoding is attempted from base64 or quoted-printable encoding, returns undecoded string if decoding failed. |
| param | int | &$mid message id |
| param | str | $pid part id |
| param | int | $action |
| param | str | $get_mime MIME type to look for. |
| param | int | $attempt |
| return | array|string|FALSE | |
| access | public | |
| access | PHP 4.2.0 | |
| see |
$structure imap_fetchbody Mail_IMAP::getParts Mail_IMAP::_checkIfParsed Mail_IMAP::_scanMultipart |
|