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::addCc */ public function testAddCc() { $this->_message->addCc('cc'); $this->assertEquals(array('cc'), $this->_message->getTo()); $this->_message->addCc(array('cc1', 'cc2')); $this->assertEquals(array('cc', 'cc1', 'cc2'), $this->_message->getTo()); }
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; }