/** * Mandrill constructor. * @param \Ebizmarts\Mandrill\Helper\Data $helper */ public function __construct(\Ebizmarts\Mandrill\Helper\Data $helper) { $apiKey = $helper->getApiKey(); if ($apiKey != '') { $this->_api = new \Mandrill($apiKey); } }
/** * @param \Ebizmarts\Mandrill\Helper\Data $helper */ public function __construct(\Ebizmarts\Mandrill\Helper\Data $helper) { $this->_helper = $helper; $apiKey = $helper->getApiKey(); if ($apiKey) { try { $this->_api = new \Mandrill($apiKey); $this->_options = $this->_api->users->info(); } catch (Mandrill_Error $e) { $this->_options = 'Invalid APIKEY'; } } }
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; }