public function MailhandlerPhpImapRetrieve::get_parts in Mailhandler 7.2
Same name and namespace in other branches
- 6.2 modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php \MailhandlerPhpImapRetrieve::get_parts()
Returns an array of parts as file objects.
Parameters
object $stream: The IMAP stream.
int $msg_number: The message number.
Return value
array An array of message parts (text body, html body, and attachments).
1 call to MailhandlerPhpImapRetrieve::get_parts()
- MailhandlerPhpImapRetrieve::retrieve_message in modules/
mailhandler_php_imap/ plugins/ mailhandler/ retrieve/ MailhandlerPhpImapRetrieve.class.php - Retrieve individual messages from an IMAP result.
File
- modules/
mailhandler_php_imap/ plugins/ mailhandler/ retrieve/ MailhandlerPhpImapRetrieve.class.php, line 192 - Definition of MailhandlerPhpImapRetrieve class.
Class
- MailhandlerPhpImapRetrieve
- Retrieve messages using PHP IMAP library.
Code
public function get_parts($stream, $msg_number) {
$parts = array(
'text_body' => '',
'html_body' => '',
'attachments' => array(),
);
// Load structure.
if (!($structure = imap_fetchstructure($stream, $msg_number))) {
mailhandler_report('error', 'Could not fetch structure for message number %msg_number', array(
'%msg_number' => $msg_number,
));
}
// Get message parts.
if ($structure->type == TYPEMULTIPART) {
// Multi-part message.\r
foreach ($structure->parts as $index => $sub_structure) {
$this
->get_part($stream, $msg_number, $sub_structure, $index + 1, $parts);
}
}
else {
// Single-part message.
$this
->get_part($stream, $msg_number, $structure, FALSE, $parts);
}
return $parts;
}