Retrieves related parts if the message is a multipart/related message, returns FALSE if there are no related parts.
The optional $secureMIME argument allows the types of files allowed in a multipart/related message to be limited. This feature can be used to prevent the browser from automatically downloading potentially malicious files embedded in a message.
<?php
require_once 'Mail/IMAP.php';
$msg =& new Mail_IMAP();
// Open up a mail connection
if (!$msg->connect('imap://'.urlencode('user@domain.com').':password@mail.example.com:143/INBOX')) {
echo "<span style='font-weight: bold;'>Error:</span> Unable to build a connection.<br/> ";
echo $msg->alerts();
echo $msg->errors();
// See if ErrorStack has any errors.
if ($msg->error->hasErrors()) {
echo "<pre> ";
var_dump($msg->error->getErrors(TRUE));
echo "</pre> ";
}
}
// Get Parts
$msg->getParts($_GET['mid'], $_GET['pid']);
// Get Related Parts
// The MIME types of the related parts are limited in the $secureMIME argument.
$related = $msg->getRelatedParts(
$_GET['mid'],
$_GET['pid'],
array(
'text/plain',
'text/html',
'text/css',
'image/jpeg',
'image/pjpeg',
'image/gif',
'image/png',
'image/x-png',
'application/xml',
'application/xhtml+xml',
'text/xml'
)
);
if ($related) {
// Do your own CID replacement algorithm
// Dump information to see how it is structured
echo "<pre> ";
var_dump($related);
echo "</pre> ";
}
?>
| param | int | &$mid message id |
| param | str | &$pid part id. |
| param | bool | $secureMIME (optional) See above. |
| return | array|FALSE | |
| throws | Error: Message structure does not exist. | The method was unable to find the message structure associated with the message id passed. |
| access | public | |
There are no comments posted at this time.
* All comments are moderated and are subject to approval.
Your comment will appear once it has been approved.
Posting multiple times will not expedite the approval process.
Comments are closed at this time.