Comments (5)
This is how the file should look like to me.
<?php
/**
* Ebizmarts_Mandrill Magento JS component
*
* @category Ebizmarts
* @package Ebizmarts_Mandrill
* @author Ebizmarts Team <[email protected]>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Ebizmarts\Mandrill\Model;
class Transport implements \Magento\Framework\Mail\TransportInterface
{
/**
* @var \Ebizmarts\Mandrill\Model\Message
*/
private $message;
/**
* @var Api\Mandrill
*/
private $api;
/**
* @param \Magento\Framework\Mail\MessageInterface $message
* @param \Psr\Log\LoggerInterface $logger
* @param \Ebizmarts\Mandrill\Helper\Data $helper
*/
public function __construct(
\Ebizmarts\Mandrill\Model\Message $message,
\Ebizmarts\Mandrill\Model\Api\Mandrill $api
) {
$this->message = $message;
$this->api = $api;
}
public function sendMessage()
{
$mandrillApiInstance = $this->getMandrillApiInstance();
if ($mandrillApiInstance === null) {
return false;
}
$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;
}
$result = $mandrillApiInstance->messages->send($message);
$this->processApiCallResult($result);
return true;
}
private function processApiCallResult($result)
{
$currentResult = current($result);
if (array_key_exists('status', $currentResult) && $currentResult['status'] == 'rejected') {
throw new \Magento\Framework\Exception\MailException(
new \Magento\Framework\Phrase("Email sending failed: %1", [$currentResult['reject_reason']])
);
}
}
/**
* @return \Mandrill
*/
private function getMandrillApiInstance()
{
return $this->api->getApi();
}
/**
* Needed to be added otherwise during setup:di:compile you'll get an error.
*
* @return string
*/
public function getMessage(){return;}
}
from magento2-mandrill.
Thanks Leon. 2.2 is not stable yet so do not expect the current stable release to be compatible with it. We will release a compatible version of this extension shortly.
from magento2-mandrill.
Can you please add that function. All the other function do work, but this one not, because you implement an interface that got that function in it. it needs to be added to transport otherwise i cant use mandrill on magento 2 and i need to make a core change to your module. is it possible to make a new branch for 2.2 where you add that function?
from magento2-mandrill.
#51 is a fix for this - and it actually returns the message object like it's supposed to.
from magento2-mandrill.
from magento2-mandrill.
Related Issues (20)
- Error thrown in Magento 2.3 when mandrill is not enabled. HOT 5
- Error while sending test email (storeId hardcoded)
- Shipment emails - When got hard bounce - trials every 1 minute HOT 11
- Order Emails Not Sending 2.2.8 CE - Test Email Works HOT 1
- Version 3.2.7 Not Working with Magento 2.2.8 HOT 1
- Magento 2.3.1 Invalid Sender (Fix) HOT 6
- Mandrill stops working on Magento 2.3.2 HOT 1
- Error thrown in Magento 2.3.1: Call to a member function toString() on string HOT 1
- from_name and from_email are set to null on Magento2.3.1 HOT 1
- mandril install by putty show error HOT 3
- Mandrill Config Not Showing in Admin Panel HOT 2
- Readme.md fails to describe or link what Mandrill is or what this extension does HOT 1
- Error when sending emails HOT 2
- Extension Not compatible /broken with 2.3.3 HOT 1
- M2.3.3 Critical Error - Wrong Invalid argument passed Ebizmarts\Mandrill\Model\Transport constructor HOT 1
- Magento 2.3.3 Incompatibility HOT 2
- Error when sending Test email for Magento 2.3.3 HOT 1
- Couldnt send test Emails HOT 7
- Error while run composer with php 7.3.14 HOT 1
- 3.3.16 - Error During Configuration & eMails not being sent HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magento2-mandrill.