/** * send one message through smtp * * @param Expressomail_Model_Message $_message * @return Expressomail_Model_Message */ public function sendMessage(Expressomail_Model_Message $_message) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Sending message with subject ' . $_message->subject . ' to ' . print_r($_message->to, TRUE)); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_message->toArray(), TRUE)); } // increase execution time (sending message with attachments can take a long time) $oldMaxExcecutionTime = Tinebase_Core::setExecutionLifeTime(300); // 5 minutes $account = Expressomail_Controller_Account::getInstance()->get($_message->account_id); $this->_resolveOriginalMessage($_message); $mail = $this->createMailForSending($_message, $account); date_default_timezone_set(Tinebase_Core::getUserTimezone()); //fetch date header to use GMT $this->_sendMailViaTransport($mail, $account, $_message, true); // get an array with all recipients $recipients = $this->_getRecipients($_message); $nonPrivateRecipients = array_merge($recipients['to'], $recipients['cc']); $allRecipients = array_merge($recipients['bcc'], $nonPrivateRecipients); $config = Tinebase_Core::getConfig(); $maxRecipients = Expressomail_Config::getInstance()->get(Expressomail_Config::MAX_CONTACT_ADD_TO_UNKNOWN); if (isset($config->email->maxContactAddToUnknown)) { $maxRecipients = $config->email->maxContactAddToUnknown; } if (count($allRecipients) <= $maxRecipients && $_message->add_contacts) { Tinebase_Core::getLogger()->debug(__METHOD__ . ' Starting search and import of ' . count($allRecipients) . ' contacts'); $_message->added_contacts = $this->_saveUnknownContacts($account->user_id, $allRecipients); Tinebase_Core::getLogger()->debug(__METHOD__ . ' Search and import completed, ' . $_message->added_contacts . ' where added'); } if ($_message->note) { // save note to contacts $this->_addEmailNote($nonPrivateRecipients, $_message->subject, $_message->getPlainTextBody()); } // reset max execution time to old value Tinebase_Core::setExecutionLifeTime($oldMaxExcecutionTime); $this->removeTempFiles($_message); return $_message; }
/** * Process a multipart/report message and returns an user friendly Html formatted body * * @param Expressomail_Model_Message $_message * @param type $_partId * @param type $_contentType * @param type $_account * @return string processed message body */ protected function _getMultipartReportMessageBody(Expressomail_Model_Message $_message, $_partId, $_contentType, $_account = NULL) { $structure = $_message->getPartStructure($_partId); $bodyParts = $_message->getBodyParts($structure, $_contentType); // test if we have all the parts if (empty($bodyParts) || count($bodyParts) < 2 || count($bodyParts) > 3 || !isset($bodyParts[2]['contentType']) && $bodyParts[2]['contentType'] !== Expressomail_Model_Message::CONTENT_TYPE_MESSAGE_DELIVERYSTATUS) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Malformed DSN Message.'); Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Message Model Dump:.' . print_r($_message->toArray(), true)); return ''; } // delivery status parts are always partId 2 $bodyPart = $this->getMessagePart($_message, 2, TRUE, $structure); $dsn = new Expressomail_Model_DeliveryStatusNotificationMessagePart($this->_getDecodedBodyContent($bodyPart, $structure)); return $dsn->getHTMLFormatted(); }