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::setReplyTo * @covers Ebizmarts\Mandrill\Model\Message::getMessageType */ public function testSetReplyTo() { $this->_message->setReplyTo("*****@*****.**", "ebizmarts"); $h = $this->_message->getHeaders(); $this->assertEquals($h[0]['Reply-To'], 'ebizmarts <*****@*****.**>'); $this->_message->setReplyTo("info@ebizmarts.com\n\t<", "<ebizmarts>"); $h = $this->_message->getHeaders(); $this->assertEquals($h[0]['Reply-To'], 'ebizmarts <*****@*****.**>'); }
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; }