public function sendMessage() { $message = array('subject' => $this->_message->getSubject(), 'from_name' => $this->_message->getFromName(), 'from_email' => $this->_message->getFrom()); foreach ($this->_message->getTo() as $to) { $message['to'][] = array('email' => $to); } foreach ($this->_message->getBcc() as $bcc) { $message['to'][] = array('email' => $bcc, 'type' => 'bcc'); } if ($att = $this->_message->getAttachments()) { $message['attachments'] = $att; } if ($headers = $this->_message->getHeaders()) { $message['headers'] = $headers; } switch ($this->_message->getType()) { case \Magento\Framework\Mail\MessageInterface::TYPE_HTML: $message['html'] = $this->_message->getBody(); break; case \Magento\Framework\Mail\MessageInterface::TYPE_TEXT: $message['text'] = $this->_message->getBody(); break; } $this->_api->getApi()->messages->send($message); return true; }
/** * @covers Ebizmarts\Mandrill\Model\Message::setMessageType * @covers Ebizmarts\Mandrill\Model\Message::getMessageType * @covers Ebizmarts\Mandrill\Model\Message::getType */ public function testSetMessageType() { $this->_message->setMessageType('mt'); $this->assertEquals('mt', $this->_message->getMessageType()); $this->assertEquals('mt', $this->_message->getType()); }
public function sendMessage() { $apiKey = $this->_helper->getApiKey(); $api = new \Mandrill($apiKey); $message = array('subject' => $this->_message->getSubject(), 'from_name' => $this->_message->getFromName(), 'from_email' => $this->_message->getFrom()); foreach ($this->_message->getTo() as $to) { $message['to'][] = array('email' => $to); } foreach ($this->_message->getBbc() as $bcc) { $message['to'][] = array('email' => $bcc, 'type' => 'bcc'); } if ($att = $this->_message->getAttachments()) { $message['attachments'] = $att; } if ($headers = $this->_message->getHeaders()) { $message['headers'] = $headers; } switch ($this->_message->getType()) { case \Magento\Framework\Mail\MessageInterface::TYPE_HTML: $message['html'] = $this->_message->getBody(); break; case \Magento\Framework\Mail\MessageInterface::TYPE_TEXT: $message['text'] = $this->_message->getBody(); break; } $api->call('messages/send', array("message" => $message)); return; }