From 92df8202ed7b37ae46df333d35bb158f2774add1 Mon Sep 17 00:00:00 2001 From: Maxim Date: Wed, 1 Feb 2017 14:10:01 +0300 Subject: [PATCH 1/4] Clear Recipients before Email Template send --- app/code/local/Aschroder/SMTPPro/Model/Email/Template.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php b/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php index 923d5b4..b55d073 100644 --- a/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php +++ b/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php @@ -76,6 +76,7 @@ public function send($email, $name = null, array $variables = array()) /** @var $emailQueue Mage_Core_Model_Email_Queue */ $emailQueue = $this->getQueue(); + $emailQueue->clearRecipients(); $emailQueue->setMessageBody($text); $emailQueue->setMessageParameters(array( 'subject' => $subject, From a9f5bc24befda3c8840dd6b5273edf660130a6fc Mon Sep 17 00:00:00 2001 From: Maxim Date: Wed, 1 Feb 2017 14:34:35 +0300 Subject: [PATCH 2/4] fix padding --- app/code/local/Aschroder/SMTPPro/Model/Email/Template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php b/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php index b55d073..6a3ce1a 100644 --- a/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php +++ b/app/code/local/Aschroder/SMTPPro/Model/Email/Template.php @@ -76,7 +76,7 @@ public function send($email, $name = null, array $variables = array()) /** @var $emailQueue Mage_Core_Model_Email_Queue */ $emailQueue = $this->getQueue(); - $emailQueue->clearRecipients(); + $emailQueue->clearRecipients(); $emailQueue->setMessageBody($text); $emailQueue->setMessageParameters(array( 'subject' => $subject, From 03ff848f162f30aa8e0a473eb6c3f118d37214cb Mon Sep 17 00:00:00 2001 From: Denis Kochnov Date: Wed, 29 Mar 2017 15:53:04 +0300 Subject: [PATCH 3/4] Refs #10652: Aschroder_SMTPPro_Model_Email_Queue - fix queue send method to continue sending and mark mail as processed if non protocol error occurs Aschroder SMTPPro - fix admin module configuration file to allow multi store configuration --- .../Aschroder/SMTPPro/Model/Email/Queue.php | 10 ++++- .../local/Aschroder/SMTPPro/etc/system.xml | 42 +++++++++---------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php b/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php index 8a2fe7b..f3bfd27 100644 --- a/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php +++ b/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php @@ -126,7 +126,15 @@ public function send() Mage::logException($e); Mage::setIsDeveloperMode($oldDevMode); - return false; + // 553 - Requested action not taken: mailbox name not allowed + if ($e instanceof Zend_Mail_Protocol_Exception && $e->getCode() != 553) { + return false; + } + + $message->setProcessedAt(Varien_Date::formatDate(true)); + $message->save(); + + continue; } // after each valid message has been sent - pause if required diff --git a/app/code/local/Aschroder/SMTPPro/etc/system.xml b/app/code/local/Aschroder/SMTPPro/etc/system.xml index d81e468..25283b0 100644 --- a/app/code/local/Aschroder/SMTPPro/etc/system.xml +++ b/app/code/local/Aschroder/SMTPPro/etc/system.xml @@ -5,8 +5,8 @@ 600 1 - 0 - 0 + 1 + 1 @@ -17,8 +17,8 @@ text 110 1 - 0 - 0 + 1 + 1 @@ -26,7 +26,7 @@ 10 1 1 - 0 + 1 SMTP Pro Email Extension Configure your SMTP connection below. If you have any questions or would like any help please visit magesmtppro.com.]]> @@ -47,7 +47,7 @@ 20 1 1 - 0 + 1 @@ -58,7 +58,7 @@ 23 1 1 - 0 + 1 @@ -68,7 +68,7 @@ 20 1 1 - 0 + 1 @@ -79,7 +79,7 @@ 23 1 1 - 0 + 1 @@ -89,7 +89,7 @@ 20 1 1 - 0 + 1 @@ -100,7 +100,7 @@ 23 1 1 - 0 + 1 @@ -112,7 +112,7 @@ 20 1 1 - 0 + 1 @@ -123,7 +123,7 @@ 23 1 1 - 0 + 1 @@ -134,7 +134,7 @@ 20 1 1 - 0 + 1 @@ -143,7 +143,7 @@ 23 1 1 - 0 + 1 login,plain,crammd5 @@ -153,7 +153,7 @@ 26 1 1 - 0 + 1 login,plain,crammd5 @@ -162,7 +162,7 @@ 29 1 1 - 0 + 1 @@ -171,7 +171,7 @@ 32 1 1 - 0 + 1 @@ -182,7 +182,7 @@ 35 1 1 - 0 + 1 From dc483960e279c21716be7c18ede95639410fde76 Mon Sep 17 00:00:00 2001 From: Denis Kochnov Date: Fri, 4 Aug 2017 15:02:30 +0300 Subject: [PATCH 4/4] Refs #12128: Aschroder_SMTPPro_Model_Email_Queue - change queue send method to increase SMTP error codes list which allow to continue sending and mark email as processed - add log exception when queue is stopped --- .../Aschroder/SMTPPro/Model/Email/Queue.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php b/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php index f3bfd27..c142064 100644 --- a/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php +++ b/app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php @@ -9,6 +9,10 @@ */ class Aschroder_SMTPPro_Model_Email_Queue extends Mage_Core_Model_Email_Queue { + protected $finalSMTPcodesForEmail = [ + 401, 432, 441, 450, 510, 511, 512, 513, 521, 523, 530, 541, 550, 551, 553, 555 + ]; + // As per parent class - except addition of before and after send events public function send() { @@ -123,14 +127,21 @@ public function send() unset($mailer); $oldDevMode = Mage::getIsDeveloperMode(); Mage::setIsDeveloperMode(true); + Mage::logException($e); - Mage::setIsDeveloperMode($oldDevMode); - // 553 - Requested action not taken: mailbox name not allowed - if ($e instanceof Zend_Mail_Protocol_Exception && $e->getCode() != 553) { + // if SMTP code not final for email, stop queue + if ($e instanceof Zend_Mail_Protocol_Exception && + $transport->getTransport() instanceof Zend_Mail_Transport_Smtp && + !in_array($e->getCode(), $this->finalSMTPcodesForEmail) + ) { + Mage::logException(new Exception('Email Queue was stopped with error code - ' . $e->getCode())); + Mage::setIsDeveloperMode($oldDevMode); return false; } + Mage::setIsDeveloperMode($oldDevMode); + $message->setProcessedAt(Varien_Date::formatDate(true)); $message->save();