/** * 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; } }
public function testMessageString() { $string = $this->_message->setCharset('utf-8')->setTags('tag1')->setTo('*****@*****.**')->setFrom('*****@*****.**')->setReplyTo(['*****@*****.**', '*****@*****.**' => 'user'])->setCc('*****@*****.**')->setBcc('*****@*****.**')->setSubject('My Message')->toString(); $this->assertEquals('My Message - Recipients: [TO] to@email.it [CC] cc@email.it [BCC] bcc@email.it', $string); }