Skip to content

Commit

Permalink
fix: Dev mode & clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
chuccv committed Dec 3, 2024
1 parent fc7bd09 commit 0f6ede9
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions Mail/Transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,58 +97,58 @@ public function __construct(
}

/**
* Around send message
*
* @param TransportInterface $subject
* @param Closure $proceed
*
* @throws MailException
* @throws Zend_Exception
*/
public function aroundSendMessage(
TransportInterface $subject,
Closure $proceed
) {
public function aroundSendMessage(TransportInterface $subject, Closure $proceed)
{
$this->_storeId = $this->registry->registry('mp_smtp_store_id');
$message = $this->getMessage($subject);

if ($this->resourceMail->isModuleEnable($this->_storeId) && $message) {
if ($this->helper->versionCompare('2.2.8')) {
$message = Message::fromString($message->getRawMessage())->setEncoding('utf-8');
}
if (!$this->resourceMail->isModuleEnable($this->_storeId)) {
$proceed();

if (!$this->validateBlacklist($message)) {
$message = $this->resourceMail->processMessage($message, $this->_storeId);
$transport = $this->resourceMail->getTransport($this->_storeId);
try {
if (!$this->resourceMail->isDeveloperMode($this->_storeId)) {
if ($this->helper->versionCompare('2.3.3')) {
$message->getHeaders()->removeHeader("Content-Disposition");
}
$transport->send($message);
return;
}
$message = $this->getMessage($subject);
if ($this->helper->versionCompare('2.2.8')) {
$message = Message::fromString($message->getRawMessage())->setEncoding('utf-8');
}
if (!$this->validateBlacklist($message)) {
$message = $this->resourceMail->processMessage($message, $this->_storeId);
try {
if (!$this->resourceMail->isDeveloperMode($this->_storeId)) {
if ($this->helper->versionCompare('2.3.3')) {
$message->getHeaders()->removeHeader("Content-Disposition");
}
$transport = $this->resourceMail->getTransport($this->_storeId);
$transport->send($message);

if ($this->helper->versionCompare('2.2.8')) {
$messageTmp = $this->getMessage($subject);
if ($messageTmp && is_object($messageTmp)) {
$body = $messageTmp->getBody();
if (is_object($body) && $body->isMultiPart()) {
$message->setBody($body->getPartContent("0"));
}
if ($this->helper->versionCompare('2.2.8')) {
$messageTmp = $this->getMessage($subject);
if ($messageTmp && is_object($messageTmp)) {
$body = $messageTmp->getBody();
if (is_object($body) && $body->isMultiPart()) {
$message->setBody($body->getPartContent("0"));
}
}

$this->emailLog($message);
}
} catch (Exception $e) {
$this->emailLog($message, false);
throw new MailException(new Phrase($e->getMessage()), $e);
}
$this->emailLog($message);
} catch (Exception $e) {
$this->emailLog($message, false);
throw new MailException(new Phrase($e->getMessage()), $e);
}
} else {
$proceed();
}
}

/**
* @param $transport
* Get message
*
* @param TransportInterface $transport
*
* @return mixed|null
*/
Expand Down

0 comments on commit 0f6ede9

Please sign in to comment.