コード例 #1
0
 /**
  * test get smtp config
  */
 public function testGetSmtpConfig()
 {
     $smtpConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::SMTP, new Tinebase_Config_Struct())->toArray();
     $account = new Expressomail_Model_Account(array('type' => Expressomail_Model_Account::TYPE_SYSTEM));
     $accountSmtpConfig = $account->getSmtpConfig();
     if (array_key_exists('primarydomain', $smtpConfig)) {
         $this->assertContains($smtpConfig['primarydomain'], $accountSmtpConfig['username']);
     }
     if (TestServer::getInstance()->getConfig()->mailserver) {
         $this->assertEquals(TestServer::getInstance()->getConfig()->mailserver, $accountSmtpConfig['hostname']);
     }
 }
コード例 #2
0
 /**
  * send mail via transport (smtp)
  *
  * @param Zend_Mail $_mail
  * @param Expressomail_Model_Account $_account
  * @param boolean $_saveInSent
  * @param Expressomail_Model_Message $_message
  */
 protected function _sendMailViaTransport(Zend_Mail $_mail, Expressomail_Model_Account $_account, Expressomail_Model_Message $_message = NULL, $_saveInSent = false)
 {
     $smtpConfig = $_account->getSmtpConfig();
     if (!empty($smtpConfig) && array_key_exists('hostname', $smtpConfig)) {
         $transport = new Expressomail_Transport($smtpConfig['hostname'], $smtpConfig);
         // send message via smtp
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' About to send message via SMTP ...');
         }
         Tinebase_Smtp::getInstance()->sendMessage($_mail, $transport);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' successful.');
         }
         // append mail to sent folder
         if ($_saveInSent) {
             $this->_selectSentFolder($_message, $_account);
             $this->_saveInSent($transport, $_account, $this->_getAdditionalHeaders($_message));
         }
         if ($_message !== NULL) {
             // add reply/forward flags if set
             if (!empty($_message->flags) && ($_message->flags == Zend_Mail_Storage::FLAG_ANSWERED || $_message->flags == Zend_Mail_Storage::FLAG_PASSED) && $_message->original_id instanceof Expressomail_Model_Message) {
                 Expressomail_Controller_Message_Flags::getInstance()->addFlags($_message->original_id, array($_message->flags));
             }
         }
     } else {
         Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not send message, no smtp config found.');
     }
 }