function MailhandlerPhpImapRetrieve::retrieve_message in Mailhandler 6.2
Same name and namespace in other branches
- 7.2 modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php \MailhandlerPhpImapRetrieve::retrieve_message()
Retrieve individual messages from an IMAP result.
Parameters
$result: IMAP stream.
object $mailbox: Mailbox to retrieve from.
int $msg_number: IMAP message number.
string $filter_name: Mailhandler Filter plugin to use.
Return value
array|false Retrieved message, or FALSE if message cannot / should not be retrieved.
1 call to MailhandlerPhpImapRetrieve::retrieve_message()
- MailhandlerPhpImapRetrieve::retrieve in modules/
mailhandler_php_imap/ plugins/ mailhandler/ retrieve/ MailhandlerPhpImapRetrieve.class.php - Connect to mailbox and run message retrieval.
File
- modules/
mailhandler_php_imap/ plugins/ mailhandler/ retrieve/ MailhandlerPhpImapRetrieve.class.php, line 356 - Definition of MailhandlerPhpImapRetrieve class.
Class
- MailhandlerPhpImapRetrieve
- Retrieve messages using PHP IMAP library.
Code
function retrieve_message($result, $mailbox, $msg_number, $filter_name) {
extract($mailbox->settings);
$header = imap_headerinfo($result, $msg_number);
// Check to see if we should retrieve this message at all
if ($filter = mailhandler_plugin_load_class('mailhandler', $filter_name, 'filters', 'handlers')) {
if (!$filter
->fetch($header)) {
return FALSE;
}
}
// Initialize the subject in case it's missing.
if (!isset($header->subject)) {
$header->subject = '';
}
// Parse MIME parts.
$parts = $this
->get_parts($result, $msg_number);
$message = FALSE;
// Is this an empty message with no body and no mimeparts?
if (!empty($parts)) {
$imap_uid = $type == 'pop3' ? $this
->fetch_uid($mailbox, $msg_number) : imap_uid($result, $msg_number);
$message = compact('header', 'imap_uid');
$message['body_text'] = $parts['text_body'] ? $parts['text_body'] : $parts['html_body'];
$message['body_html'] = $parts['html_body'] ? $parts['html_body'] : $parts['text_body'];
$message['mimeparts'] = $parts['attachments'];
}
return $message;
}