Skip to content

Commit

Permalink
Merge pull request #1 from BudsiesApp/12117-fix-queue-sending
Browse files Browse the repository at this point in the history
Refs #12128: Aschroder_SMTPPro_Model_Email_Queue
  • Loading branch information
gorbunovav authored Aug 4, 2017
2 parents 03ff848 + dc48396 commit 8e2c906
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/code/local/Aschroder/SMTPPro/Model/Email/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 8e2c906

Please sign in to comment.