Skip to content

Commit 52cc54f

Browse files
committed
Version 1.0.4
1 parent 47433aa commit 52cc54f

File tree

19 files changed

+122
-142
lines changed

19 files changed

+122
-142
lines changed

Controller/Adminhtml/Log/Delete.php

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public function execute()
2121
} else {
2222
$this->messageManager->addErrorMessage(__('Unable to find the rule'));
2323
}
24-
2524
} catch (\Magento\Framework\Exception\LocalizedException $e) {
2625
$this->messageManager->addErrorMessage($e->getMessage());
2726
} catch (\Exception $e) {

Cron/Clear.php

100644100755
File mode changed.

Model/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function getBccEmails()
158158
protected function _getExceptionalEmails()
159159
{
160160
$allowedEmailsString = $this->config->getModuleConfig(
161-
self::XML_PATH_TEMPLATE_DEBUG . 'exeptional_email_addressesa',
161+
self::XML_PATH_TEMPLATE_DEBUG . 'exeptional_email_addresses',
162162
$this->getCurrentStoreId()
163163
);
164164

Model/Framework/Mail/Transport.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function sendMessage()
159159
$this->message = $this->aitConfig->prepareMessageToSend($this->getMessage());
160160

161161
if ($this->aitConfig->isNewSender(RegistryConstants::VERSION_COMPARISON_OLD_MAIL)) {
162-
$message = ZendMessage::fromString($this->message->getRawMessage());
162+
$message = ZendMessage::fromString($this->message->getRawMessage())->setEncoding('utf-8');
163163
} else {
164164
$message = $this->message;
165165
}
@@ -214,7 +214,7 @@ private function getLoger()
214214
public function modifyTo()
215215
{
216216
if ($this->aitConfig->isNewSender(RegistryConstants::VERSION_COMPARISON_OLD_MAIL)) {
217-
$message = ZendMessage::fromString($this->message->getRawMessage());
217+
$message = ZendMessage::fromString($this->message->getRawMessage())->setEncoding('utf-8');
218218
} else {
219219
$message = $this->message;
220220
}
@@ -268,7 +268,7 @@ public function testSend($to)
268268
->setBodyText(__(self::TEST_MESSAGE_BODY));
269269

270270
if ($this->aitConfig->isNewSender(RegistryConstants::VERSION_COMPARISON_OLD_MAIL)) {
271-
$message = ZendMessage::fromString($this->message->getRawMessage());
271+
$message = ZendMessage::fromString($this->message->getRawMessage())->setEncoding('utf-8');
272272
} else {
273273
$message = $this->message;
274274
}

Model/Html2Text.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ static function nextChildName($node) {
194194
return $nextName;
195195
}
196196

197-
static function iterateOverNode($node, $prevName = null, $in_pre = false, $is_office_document = false, $options) {
197+
static function iterateOverNode($node, $prevName = null, $in_pre = false, $is_office_document = false, $options = [])
198+
{
198199
if ($node instanceof \DOMText) {
199-
// Replace whitespace characters with a space (equivilant to \s)
200+
// Replace whitespace characters with a space (equivalent to \s)
200201
if ($in_pre) {
201202
$text = "\n" . trim(static::renderText($node->wholeText), "\n\r\t ") . "\n";
202203
// Remove trailing whitespace only
@@ -424,4 +425,4 @@ static function iterateOverNode($node, $prevName = null, $in_pre = false, $is_of
424425
}
425426
return $output;
426427
}
427-
}
428+
}

Model/ResourceModel/Log.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66

77
class Log extends AbstractDb
88
{
9+
/**
10+
* Smtp Log Store Table Name
11+
*/
12+
const AITOC_SMTP_LOG_TABLE_NAME = 'aitoc_smtp_log';
13+
914
/**
1015
* {@inheritdoc}
1116
*/
1217
protected function _construct()
1318
{
1419
$this->_init(
15-
\Aitoc\Smtp\Setup\InstallSchema::AITOC_SMTP_LOG_TABLE_NAME,
20+
self::AITOC_SMTP_LOG_TABLE_NAME,
1621
\Aitoc\Smtp\Model\Log::LOG_ID_TYPE_FIELD
1722
);
1823
}
19-
}
24+
}

Model/Sender.php

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44

55
use Aitoc\Smtp\Api\Data\LogInterface;
66
use Aitoc\Smtp\Controller\RegistryConstants;
7-
use Magento\Store\Model\Store;
7+
use Aitoc\Smtp\Model\Config\Options\Status;
88
use Magento\Framework\App\Area;
99
use Magento\Framework\Exception\MailException;
10-
use Aitoc\Smtp\Model\Config\Options\Status;
10+
use Magento\Store\Model\Store;
1111

12-
/**
13-
* Class Sender
14-
* @package Aitoc\Smtp\Model
15-
*/
1612
class Sender
1713
{
14+
const ADDRESS_SCOPE_FROM = 'from';
15+
const ADDRESS_SCOPE_TO = 'to';
16+
1817
/**
1918
* @var LogFactory
2019
*/
@@ -30,6 +29,11 @@ class Sender
3029
*/
3130
private $config;
3231

32+
/**
33+
* @param LogFactory $logFactory
34+
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
35+
* @param Config $config
36+
*/
3337
public function __construct(
3438
\Aitoc\Smtp\Model\LogFactory $logFactory,
3539
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
@@ -41,8 +45,12 @@ public function __construct(
4145
}
4246

4347
/**
44-
* @param $logId
48+
* Send the Email using log Id
49+
*
50+
* @param int $logId
4551
* @return bool
52+
* @throws MailException
53+
* @throws \Magento\Framework\Exception\LocalizedException
4654
*/
4755
public function sendByLogId($logId)
4856
{
@@ -64,12 +72,12 @@ public function sendByLogId($logId)
6472
return false;
6573
}
6674

67-
$vars[LogInterface::EMAIL_BODY] = $data[LogInterface::EMAIL_BODY];
75+
$vars[LogInterface::EMAIL_BODY] = quoted_printable_decode($data[LogInterface::EMAIL_BODY]);
6876
$vars[LogInterface::SUBJECT] = $data[LogInterface::SUBJECT];
6977

7078
$this->transportBuilder
71-
->addTo($this->prepareEmailsData($data[LogInterface::RECIPIENT_EMAIL]))
72-
->setFrom($this->prepareEmailsData($data[LogInterface::SENDER_EMAIL], true));
79+
->addTo($this->prepareEmailsData($data[LogInterface::RECIPIENT_EMAIL], self::ADDRESS_SCOPE_TO))
80+
->setFromByScope($this->prepareEmailsData($data[LogInterface::SENDER_EMAIL], self::ADDRESS_SCOPE_FROM));
7381

7482
if ($data[LogInterface::BCC]) {
7583
$this->transportBuilder->addBcc($this->prepareEmailsData($data[LogInterface::BCC]));
@@ -102,35 +110,45 @@ public function sendByLogId($logId)
102110
}
103111

104112
/**
105-
* @param $emails
106-
* @param bool $from
107-
* @return array|\Zend\Mail\AddressList
113+
* Prepare the Data for Send Email
114+
*
115+
* @param array $emails
116+
* @param string $scope
117+
* @return array|mixed|string|\Zend\Mail\AddressList
108118
*/
109-
private function prepareEmailsData($emails, $from = false)
119+
private function prepareEmailsData($emails, $scope = '')
110120
{
111121
$emailsConverted = [];
112122
$emails = explode(',', $emails);
113123
foreach ($emails as $email) {
114124
$emailData = explode('>', substr($email, 1));
115125

116-
if ($from) {
117-
return [
118-
'name' => ($emailData[0] == 'Unknown' ? null : $emailData[0]),
119-
'email' => $emailData[1],
120-
];
121-
} else {
122-
$emailsConverted[] = [
123-
'name' => ($emailData[0] == 'Unknown' ? null : $emailData[0]),
124-
'email' => $emailData[1],
125-
];
126+
switch ($scope) {
127+
case self::ADDRESS_SCOPE_TO:
128+
return $emailData[1];
129+
break;
130+
131+
case self::ADDRESS_SCOPE_FROM:
132+
return [
133+
'name' => ($emailData[0] == 'Unknown' ? '' : $emailData[0]),
134+
'email' => $emailData[1],
135+
];
136+
break;
126137
}
138+
$emailsConverted[] = [
139+
'name' => ($emailData[0] == 'Unknown' ? '' : $emailData[0]),
140+
'email' => $emailData[1],
141+
];
127142
}
128143

129144
return $this->config->getAddressList($emailsConverted);
130145
}
131146

132147
/**
133-
* @return mixed
148+
* Get the Current Log Details using Log Id
149+
*
150+
* @param int $logId
151+
* @return Log
134152
*/
135153
public function getCurrentLog($logId)
136154
{

Plugin/Framework/Mail/TransportInterfaceFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function aroundCreate($subject, $proceed, array $data = [])
4848
unset($data[RegistryConstants::IS_TEST_FIELD_ARRAY]);
4949
$config = $data;
5050
$data['message'] = $this->objectManager->create(\Magento\Framework\Mail\Message::class);
51-
5251
} else {
5352
$config = $this->config->getFullConfig();
5453
}

Setup/InstallSchema.php

Lines changed: 0 additions & 92 deletions
This file was deleted.

User Guide.pdf

-485 KB
Binary file not shown.

0 commit comments

Comments
 (0)