示例#1
0
/**
 * Extract body from MailboxManagerEmail and modify it so we can use it in activecollab
 *
 * @param MailboxManagerEmail $email
 * @return string
 */
function incoming_mail_get_body(&$email)
{
    $body = $email->getBody('text/plain');
    if ($body) {
        // if we have plain email to start with
        $body_lines = explode("\n", $body);
        incoming_mail_convert_plain_text_quotes_to_blockquotes($body_lines);
        incoming_mail_convert_plain_signature_to_blockquote($body_lines);
        incoming_mail_convert_reply_to_blockquote($body_lines);
        $body = implode("\n", $body_lines);
    } else {
        // if we have html email to start with
        $body = $email->getBody('text/html');
        if (!trim($body)) {
            return false;
        }
        // if
        $body = html_to_plain_email($body);
        $body_lines = explode("\n", $body);
        incoming_mail_convert_plain_signature_to_blockquote($body_lines);
        incoming_mail_convert_reply_to_blockquote($body_lines);
        $body = implode("<br />", $body_lines);
    }
    // if
    return trim($body);
}
 /**
  * Parse singlepart message
  *
  * @param integer $message_id
  * @param stdObj $structure
  * @param MailboxManagerEmail $email
  * @return MailboxManagerEmail
  */
 function parseMessageSinglepartBody($message_id, &$structure, &$email)
 {
     $content_type = $this->getContentType($structure);
     $type = $this->getMainContentType($structure->type);
     $sub_type = $this->getSubContentType($structure->subtype);
     $charset = strtoupper($this->getPartParameter($structure, 'charset'));
     $encoding = $this->getBodyEncodingString($structure->encoding);
     $content = imap_body($this->getConnection(), $message_id);
     switch ($encoding) {
         case 'base64':
             $content = imap_base64($content);
             break;
         case 'quoted-printable':
             $content = imap_qprint($content);
             break;
     }
     // switch
     $content = $charset == 'UTF-8' ? $content : convert_to_utf8($content, $charset);
     $email->addBody('0', $content_type, $content);
     return $email;
 }