public function testChangeMessageAsyncMode()
 {
     $this->assertFalse($this->_message->isAsync());
     $this->assertInstanceOf('\\nickcv\\mandrill\\Message', $this->_message->enableAsync());
     $this->assertTrue($this->_message->isAsync());
     $this->assertInstanceOf('\\nickcv\\mandrill\\Message', $this->_message->disableAsync());
     $this->assertFalse($this->_message->isAsync());
 }
Пример #2
0
 /**
  * Sends the specified message.
  *
  * @param Message $message the message to be sent
  * @return boolean whether the message is sent successfully
  */
 protected function sendMessage($message)
 {
     \Yii::info('Sending email "' . $message->getSubject() . '" to "' . implode(', ', $message->getTo()) . '"', self::LOG_CATEGORY);
     try {
         if ($this->useMandrillTemplates) {
             return $this->wasMessageSentSuccesfully($this->_mandrill->messages->sendTemplate($message->getTemplateName(), $message->getTemplateContent(), $message->getMandrillMessageArray(), $message->isAsync()));
         } else {
             return $this->wasMessageSentSuccesfully($this->_mandrill->messages->send($message->getMandrillMessageArray(), $message->isAsync()));
         }
     } catch (Mandrill_Error $e) {
         \Yii::error('A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage(), self::LOG_CATEGORY);
         return false;
     }
 }