/** * the singleton pattern * * @return Felamimail_Controller_Message_Send */ public static function getInstance() { if (self::$_instance === NULL) { self::$_instance = new Felamimail_Controller_Message_Send(); } return self::$_instance; }
/** * this function generates the response for the client * * @return void */ public function getResponse() { $rfc822 = Felamimail_Controller_Message::getInstance()->getMessagePart($this->_itemId); $rfc822->type = Felamimail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822; $rfc822->filename = 'forwarded email.eml'; $rfc822->encoding = Zend_Mime::ENCODING_7BIT; $mail = Tinebase_Mail::createFromZMM($this->_incomingMessage); $mail->addAttachment($rfc822); Felamimail_Controller_Message_Send::getInstance()->sendZendMail($this->_account, $mail, $this->_saveInSent); }
/** * Send the reading confirmation in a message who has the correct header and is not seen yet * * @return void */ public function sendReadingConfirmation() { if (!is_array($this->headers)) { $this->headers = Felamimail_Controller_Message::getInstance()->getMessageHeaders($this->getId(), NULL, TRUE); } if ((isset($this->headers['disposition-notification-to']) || array_key_exists('disposition-notification-to', $this->headers)) && $this->headers['disposition-notification-to']) { $translate = Tinebase_Translation::getTranslation($this->_application); $from = Felamimail_Controller_Account::getInstance()->get($this->account_id); $message = new Felamimail_Model_Message(); $message->account_id = $this->account_id; $punycodeConverter = Felamimail_Controller_Message::getInstance()->getPunycodeConverter(); $to = Felamimail_Message::convertAddresses($this->headers['disposition-notification-to'], $punycodeConverter); if (empty($to)) { throw new Felamimail_Exception('disposition-notification-to header does not contain a valid email address'); } $message->content_type = Felamimail_Model_Message::CONTENT_TYPE_HTML; $message->to = $to[0]['email']; $message->subject = $translate->_('Reading Confirmation:') . ' ' . $this->subject; $message->body = $translate->_('Your message:') . ' ' . $this->subject . "\n" . $translate->_('Received on') . ' ' . $this->received . "\n" . $translate->_('Was read by:') . ' ' . $from->from . ' <' . $from->email . '> ' . $translate->_('on') . ' ' . date('Y-m-d H:i:s'); $message->body = Tinebase_Mail::convertFromTextToHTML($message->body, 'felamimail-body-blockquote'); Felamimail_Controller_Message_Send::getInstance()->sendMessage($message); } }
/** * test converting to punycode */ public function testEncodeToPunycode() { $message = new Felamimail_Model_Message(array('to' => array('albert@östermänn.org'), 'subject' => 'punycode test')); $mail = Felamimail_Controller_Message_Send::getInstance()->createMailForSending($message, $this->_account); $recipients = $mail->getRecipients(); $this->assertEquals('*****@*****.**', $recipients[0]); }
/** * save message in folder * * @param string $folderName * @param array $recordData * @return array */ public function saveMessageInFolder($folderName, $recordData) { $message = new Felamimail_Model_Message(); $message->setFromJsonInUsersTimezone($recordData); $result = Felamimail_Controller_Message_Send::getInstance()->saveMessageInFolder($folderName, $message); $result = $this->_recordToJson($result); return $result; }
/** * send email * * @param resource $inputStream * @param boolean $saveInSent * @throws Syncroton_Exception */ public function sendEmail($inputStream, $saveInSent) { $account = $this->_getAccount(); if (!$account) { if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . " no email account configured"); } throw new Syncroton_Exception('no email account configured'); } if (empty(Tinebase_Core::getUser()->accountEmailAddress)) { throw new Syncroton_Exception('no email address set for current user'); } if (!is_resource($inputStream)) { $stream = fopen("php://temp", 'r+'); fwrite($stream, $inputStream); $inputStream = $stream; rewind($inputStream); } if ($this->_debugEmail == true) { $debugStream = fopen("php://temp", 'r+'); stream_copy_to_stream($inputStream, $debugStream); rewind($debugStream); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " email to send:" . stream_get_contents($debugStream)); } //replace original stream wirh debug stream, as php://input can't be rewinded $inputStream = $debugStream; rewind($inputStream); } $incomingMessage = new Zend_Mail_Message(array('file' => $inputStream)); $subject = $incomingMessage->headerExists('subject') ? $incomingMessage->getHeader('subject') : null; if (Tinebase_Mail::isiMIPMail($incomingMessage)) { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Do not send iMIP message with subject "' . $subject . '". The server should handle those.'); } } else { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Send Message with subject " . $subject . " (saveInSent: " . $saveInSent . ")"); } $mail = Tinebase_Mail::createFromZMM($incomingMessage); Felamimail_Controller_Message_Send::getInstance()->sendZendMail($account, $mail, (bool) $saveInSent); } }
public function inviteUsersToJoinToFelamimail($roomId, $moderator, $userName, $email) { $translation = Tinebase_Translation::getTranslation('Webconference'); $defaultEmailAccount = Tinebase_Core::getPreference("Felamimail")->{Felamimail_Preference::DEFAULTACCOUNT}; $url = Webconference_Controller_BigBlueButton::getInstance()->joinRoom($roomId, $moderator, $userName, $email)->bbbUrl->bbbUrl; $accountFullName = Tinebase_Core::getUser()->accountFullName; $messageHtml = sprintf($translation->_("The user %s is inviting you to a Webconference"), $accountFullName); $messageHtml .= "<br/><br/>"; $messageHtml .= "<div>"; $messageHtml .= "<span class=\"{$url}\" />"; $messageHtml .= "<span class=\"tinebase-webconference-link\">"; $messageHtml .= $translation->_("Log in to Webconference"); $messageHtml .= "</span>"; $messageHtml .= "</div>"; $recordData = array("note" => null, "content_type" => "text/html", "account_id" => $defaultEmailAccount, "to" => array($email), "cc" => array(), "bcc" => array(), "subject" => $translation->_("Invite User To Join Webconference"), "body" => $messageHtml, "attachments" => array(), "from_email" => Tinebase_Core::getUser()->accountEmailAddress, "customfields" => array()); $message = new Felamimail_Model_Message(); $message->setFromArray($recordData); try { $result = Felamimail_Controller_Message_Send::getInstance()->sendMessage($message); $result = $this->_recordToJson($result); } catch (Zend_Mail_Protocol_Exception $zmpe) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not send message: ' . $zmpe->getMessage()); throw $zmpe; } return $result; }
/** * this function generates the response for the client * * @return void */ public function getResponse() { $replyBody = Felamimail_Controller_Message::getInstance()->getMessageBody($this->_itemId, null, 'text/plain'); $mail = Tinebase_Mail::createFromZMM($this->_incomingMessage, $replyBody); Felamimail_Controller_Message_Send::getInstance()->sendZendMail($this->_account, $mail, $this->_saveInSent); }
/** * Send the reading confirmation in a message who has the correct header and is not seen yet * * @return void */ public function sendReadingConfirmation() { if ($this->headers['disposition-notification-to'] && !$this->hasSeenFlag()) { $translate = Tinebase_Translation::getTranslation($this->_application); $from = Felamimail_Controller_Account::getInstance()->get($this->account_id); $message = new Felamimail_Model_Message(); $message->account_id = $this->account_id; $message->to = $this->headers['disposition-notification-to']; $message->subject = $translate->_('Reading Confirmation:') . ' ' . $this->subject; $message->body = $translate->_('Your message:') . ' ' . $this->subject . "\n" . $translate->_('Received in') . ' ' . $this->received . "\n" . $translate->_('Was readed by:') . ' ' . $from->from . ' <' . $from->email . '> ' . $translate->_('in') . ' ' . date('Y-m-d H:i:s'); Felamimail_Controller_Message_Send::getInstance()->sendMessage($message); } }
/** * this function generates the response for the client * * @return void */ public function getResponse() { $mail = Tinebase_Mail::createFromZMM($this->_incomingMessage); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " saveInSent: " . (int) $this->_saveInSent); } Felamimail_Controller_Message_Send::getInstance()->sendZendMail($this->_account, $mail, $this->_saveInSent); }