/** * 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 execute() { $email = $this->getRequest()->getParam('email'); $template = "mandrill_test_template"; $this->_transportBuilder->setTemplateIdentifier($template); $this->_transportBuilder->setFrom($this->_helper->getTestSender()); $this->_transportBuilder->addTo($email); $this->_transportBuilder->setTemplateVars([]); $this->_transportBuilder->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => 1]); $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); // $response = new Object(); // $response->setError(0); /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); $resultJson->setData(['error' => 0]); return $resultJson; }
/** * @return bool */ public function mandrillEnabled() { return $this->_mandrillHelper->isActive(); }
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; }