Richard York

Web Developer, Author, and Artist

Mail_IMAP::getRelatedParts()

array|FALSE getRelatedParts(int &$mid, str &$pid = '0'[, array $secureMIME = array()])

Retrieves related parts if the message is a multipart/related message, returns FALSE if there are no related parts.

Limiting the types of files with the $secureMIME argument

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> "; } ?>

Method summary:

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

Comments

There are no comments posted at this time.

Leave a Comment

Simple HTML is allowed: <code>, <b>, <i>, <u>, <var>, <strong>, <em>, <blockquote>, <ul>, <ol>, <li>, <p> (no attributes). All spacing and line breaks in your comment will be preserved.

* 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.

© Copyright 2014 Hot Toddy, All Rights Reserved.