diff --git a/Controller/Adminhtml/index/Ajax.php b/Controller/Adminhtml/index/Ajax.php
old mode 100755
new mode 100644
diff --git a/Controller/Adminhtml/index/Post.php b/Controller/Adminhtml/index/Post.php
old mode 100755
new mode 100644
diff --git a/Controller/Adminhtml/index/Sync.php b/Controller/Adminhtml/index/Sync.php
old mode 100755
new mode 100644
diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php
index 3a09c89..8b4ea10 100644
--- a/Controller/Index/Index.php
+++ b/Controller/Index/Index.php
@@ -48,7 +48,7 @@ public function dubleoptinProcess($userEmail)
$mailin = $this->_model->createObjMailin($apiKey);
$data = array( "email" => $userEmail,
- "attributes" => array(),
+ "attributes" => array("DOUBLE_OPT-IN"=>1),
"blacklisted" => 0,
"listid" => array($listId),
"listid_unlink" => array($optinListId),
diff --git a/Model/SendinblueSib.php b/Model/SendinblueSib.php
index d3b545c..96b852d 100644
--- a/Model/SendinblueSib.php
+++ b/Model/SendinblueSib.php
@@ -129,9 +129,6 @@ public function createNewList($response, $existList)
);
$listResp = $mailin->createList($data);
$this->_resourceConfig->saveConfig('sendinblue/selected_list_data', trim($listResp['data']['id']), $this->_scopeTypeDefault, $this->_storeId);
- //list id
-
- $this->sendAllMailIDToSendin($listResp['data']['id']);
}
@@ -400,7 +397,7 @@ public function checkFolderList()
public function sendAllMailIDToSendin($listId)
{
$emailValue = $this->getSubscribeCustomer();
- $baseUrl = $this->_storeManagerInterface->getStore()->getBaseUrl();
+ $mediaUrl = $this->_storeManagerInterface->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
$apiKey = !empty($this->apiKey) ? $this->apiKey : $this->getDbData('api_key');
if ($emailValue > 0 && !empty($apiKey)) {
$this->updateDbData('import_old_user_status', 1);
@@ -408,7 +405,7 @@ public function sendAllMailIDToSendin($listId)
$listIdVal = explode('|', $listId);
$mailinObj = $this->createObjMailin($apiKey);
$userDataInformation['key'] = $apiKey;
- $userDataInformation['url'] = $baseUrl.'pub/media/sendinblue_csv/ImportSubUsersToSendinblue.csv';
+ $userDataInformation['url'] = $mediaUrl.'sendinblue_csv/ImportSubUsersToSendinblue.csv';
$userDataInformation['listids'] = $listIdVal; // $list;
$userDataInformation['notify_url'] = '';
$responseValue = $mailinObj->importUsers($userDataInformation);
@@ -813,9 +810,9 @@ public function importOrderhistory()
$userDataInformation = array();
$listIdVal = explode('|', $listId);
$mailinObj = $this->createObjMailin($apiKey);
- $baseUrl = $this->_storeManagerInterface->getStore()->getBaseUrl();
+ $baseUrl = $this->_storeManagerInterface->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
$userDataInformation['key'] = $apiKey;
- $userDataInformation['url'] = $baseUrl.'pub/media/sendinblue_csv/ImportOldOrdersToSendinblue.csv';
+ $userDataInformation['url'] = $baseUrl.'sendinblue_csv/ImportOldOrdersToSendinblue.csv';
$userDataInformation['listids'] = $listIdVal; // $list;
$userDataInformation['notify_url'] = '';
$responseValue = $mailinObj->importUsers($userDataInformation);
@@ -1118,11 +1115,11 @@ public function subscribeByruntime($userEmail, $updateDataInSib)
$sendinConfirmType = $this->getDbData('confirm_type');
if ($sendinConfirmType === 'doubleoptin') {
$listId = $this->getDbData('optin_list_id');
+ $updateDataInSib['DOUBLE_OPT-IN'] = 2;
} else {
$listId = $this->getDbData('selected_list_data');
}
-
$apiKey = trim($this->getDbData('api_key'));
if (!empty($apiKey)) {
$mailin = $this->createObjMailin($apiKey);
@@ -1326,11 +1323,17 @@ public function sendWsTemplateMail($to)
$to = array($to => '');
$from = array($senderEmail, $senderName);
+ $searchValue = "({{\s*doubleoptin\s*}})";
$htmlContent = str_replace('{title}', $subject, $htmlContent);
$htmlContent = str_replace('https://[DOUBLEOPTIN]', '{subscribe_url}', $htmlContent);
$htmlContent = str_replace('http://[DOUBLEOPTIN]', '{subscribe_url}', $htmlContent);
+ $htmlContent = str_replace('https://{{doubleoptin}}', '{subscribe_url}', $htmlContent);
+ $htmlContent = str_replace('http://{{doubleoptin}}', '{subscribe_url}', $htmlContent);
+ $htmlContent = str_replace('https://{{ doubleoptin }}', '{subscribe_url}', $htmlContent);
+ $htmlContent = str_replace('http://{{ doubleoptin }}', '{subscribe_url}', $htmlContent);
$htmlContent = str_replace('[DOUBLEOPTIN]', '{subscribe_url}', $htmlContent);
+ $htmlContent = preg_replace($searchValue, '{subscribe_url}', $htmlContent);
$htmlContent = str_replace('{site_name}', $siteName, $htmlContent);
$htmlContent = str_replace('{unsubscribe_url}', $pathResp, $htmlContent);
$htmlContent = str_replace('{subscribe_url}', $pathResp, $htmlContent);
diff --git a/Model/Transport.php b/Model/Transport.php
index d25af5d..b81e65c 100644
--- a/Model/Transport.php
+++ b/Model/Transport.php
@@ -4,50 +4,59 @@
*/
namespace Sendinblue\Sendinblue\Model;
-class Transport extends \Zend_Mail_Transport_Smtp implements \Magento\Framework\Mail\TransportInterface
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Mail\MessageInterface;
+use Zend\Mail\Message;
+use Zend\Mail\Transport\SmtpOptions;
+use Zend\Mail\Transport\Smtp;
+
+class Transport
{
- /**
- * @var \Magento\Framework\Mail\MessageInterface
- */
+ /** @var MessageInterface */
protected $_message;
- public $scopeConfig;
+
+ /** @var Smtp|\Zend_Mail_Transport_Smtp **/
+ protected $transport;
+
+
/**
* @param MessageInterface $message
* @param null $parameters
* @throws \InvalidArgumentException
*/
- public function __construct(\Magento\Framework\Mail\MessageInterface $message,
- \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
- )
- {
- if (!$message instanceof \Zend_Mail) {
- throw new \InvalidArgumentException('The message should be an instance of \Zend_Mail');
- }
-
- $smtpHost = '';
- $smtpConf = array();
- $relaySib = $scopeConfig->getValue('sendinblue/relay_data_status', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
-
- if ($relaySib == 'enabled') {
- $smtpHost = $scopeConfig->getValue('sendinblue/smtp_host', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- $smtpAuthentication = $scopeConfig->getValue('sendinblue/smtp_authentication', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- $smtpTls = $scopeConfig->getValue('sendinblue/smtp_tls', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- $smtpPort = $scopeConfig->getValue('sendinblue/smtp_port', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- $smtpUsername = $scopeConfig->getValue('sendinblue/smtp_username', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- $smtpPassword = $scopeConfig->getValue('sendinblue/smtp_password', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
- $smtpConf = [
- 'auth' => $smtpAuthentication,
- 'tls' => $smtpTls,
- 'port' => $smtpPort,
- 'username' => $smtpUsername,
- 'password' => $smtpPassword
- ];
-
-
- }
- parent::__construct($smtpHost, $smtpConf);
- $this->_message = $message;
-
+ public function __construct(MessageInterface $message, ScopeConfigInterface $scopeConfig ){
+ $this->_message = $message;
+
+ $relaySib = $scopeConfig->getValue('sendinblue/relay_data_status', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
+ if ($relaySib == 'enabled') {
+ $smtpHost = "smtp-relay.sendinblue.com";
+ $smtpAuthentication = $scopeConfig->getValue('sendinblue/smtp_authentication', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
+ $smtpTls = $scopeConfig->getValue('sendinblue/smtp_tls', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
+ $smtpPort = $scopeConfig->getValue('sendinblue/smtp_port', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
+ $smtpUsername = $scopeConfig->getValue('sendinblue/smtp_username', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
+ $smtpPassword = $scopeConfig->getValue('sendinblue/smtp_password', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
+
+ if ($message instanceof \Zend_mail) {
+ $this->transport = new \Zend_Mail_Transport_Smtp($smtpHost, [
+ 'auth' => $smtpAuthentication,
+ 'tls' => $smtpTls,
+ 'port' => $smtpPort,
+ 'username' => $smtpUsername,
+ 'password' => $smtpPassword
+ ]);
+ } elseif ($message instanceof MessageInterface) {
+ $this->transport = new Smtp( new SmtpOptions([
+ 'host' => $smtpHost,
+ 'port' => $smtpPort,
+ 'connection_class' => $smtpAuthentication,
+ 'connection_config' => [
+ 'username' => $smtpUsername,
+ 'password' => $smtpPassword,
+ 'ssl' => $smtpTls,
+ ],
+ ]));
+ }
+ }
}
/**
@@ -57,10 +66,16 @@ public function __construct(\Magento\Framework\Mail\MessageInterface $message,
*/
public function sendMessage()
{
- try {
- parent::send($this->_message);
- } catch (\Exception $e) {
- throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e);
+ if(null !== $this->transport){
+ try {
+ if ($this->_message instanceof \Zend_mail) {
+ $this->transport->send($this->_message);
+ } elseif ($this->_message instanceof MessageInterface) {
+ $this->transport->send(Message::fromString($this->_message->getRawMessage()));
+ }
+ } catch (\Exception $e) {
+ throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e);
+ }
}
}
diff --git a/Observer/SibNlObserver.php b/Observer/SibNlObserver.php
old mode 100755
new mode 100644
diff --git a/Observer/SibObserver.php b/Observer/SibObserver.php
old mode 100755
new mode 100644
diff --git a/Observer/SibOrderObserver.php b/Observer/SibOrderObserver.php
old mode 100755
new mode 100644
diff --git a/Observer/SibShipObserver.php b/Observer/SibShipObserver.php
old mode 100755
new mode 100644
diff --git a/Observer/SibaddrObserver.php b/Observer/SibaddrObserver.php
old mode 100755
new mode 100644
diff --git a/composer.json b/composer.json
index fbf40be..bc7ca6b 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "sendinblue/module-sendinblue",
"description": "N/A",
"type": "magento2-module",
- "version": "2.0.2",
+ "version": "2.0.3",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/etc/di.xml b/etc/di.xml
index dc6f48f..b106845 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -2,4 +2,5 @@