Skip to content

Commit

Permalink
Merge pull request #1 from BudsiesApp/master
Browse files Browse the repository at this point in the history
Clear Recipients before Email Template send aschroder#191
  • Loading branch information
tmp2000 authored Jan 27, 2018
2 parents a1f9623 + 8e2c906 commit 56d79c2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
21 changes: 20 additions & 1 deletion 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,10 +127,25 @@ public function send()
unset($mailer);
$oldDevMode = Mage::getIsDeveloperMode();
Mage::setIsDeveloperMode(true);

Mage::logException($e);

// 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);

return false;
$message->setProcessedAt(Varien_Date::formatDate(true));
$message->save();

continue;
}

// after each valid message has been sent - pause if required
Expand Down
1 change: 1 addition & 0 deletions app/code/local/Aschroder/SMTPPro/Model/Email/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 21 additions & 21 deletions app/code/local/Aschroder/SMTPPro/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<label>Aschroder Extensions</label>
<sort_order>600</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</aschroder>
</tabs>
<sections>
Expand All @@ -17,16 +17,16 @@
<frontend_type>text</frontend_type>
<sort_order>110</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<general module="smtppro" translate="label comment">
<label>General Settings</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<comment><![CDATA[<div style='background-color: #efefef;margin-bottom: 10px;height: 40px;'> <img style='float:left;width: 150px;' src='http://www.aschroder.com/smtppro-logo.png' /> <span style='float:left;font-size: 20px; margin:10px;'>SMTP Pro Email Extension</span> </div> Configure your SMTP connection below. If you have any questions or would like any help please visit <a href='http://magesmtppro.com' target='_blank'>magesmtppro.com</a>.]]></comment>
<fields>
<option translate="label">
Expand All @@ -35,8 +35,8 @@
<source_model>smtppro/system_config_source_smtp_option</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</option>


Expand All @@ -47,7 +47,7 @@
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>google</option></depends>
</googleapps_email>
<googleapps_gpassword translate="label comment">
Expand All @@ -58,7 +58,7 @@
<sort_order>23</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>google</option></depends>
</googleapps_gpassword>

Expand All @@ -68,7 +68,7 @@
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>sendgrid</option></depends>
</sendgrid_email>
<sendgrid_password translate="label comment">
Expand All @@ -79,7 +79,7 @@
<sort_order>23</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>sendgrid</option></depends>
</sendgrid_password>

Expand All @@ -89,7 +89,7 @@
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>mailup</option></depends>
</mailup_email>
<mailup_password translate="label comment">
Expand All @@ -100,7 +100,7 @@
<sort_order>23</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>mailup</option></depends>
</mailup_password>

Expand All @@ -112,7 +112,7 @@
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>ses</option></depends>
</ses_access_key>
<ses_private_key translate="label comment">
Expand All @@ -123,7 +123,7 @@
<sort_order>23</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>ses</option></depends>
</ses_private_key>

Expand All @@ -134,7 +134,7 @@
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>smtp</option></depends>
</smtp_authentication>
<smtp_username translate="label">
Expand All @@ -143,7 +143,7 @@
<sort_order>23</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>smtp</option><smtp_authentication separator=",">login,plain,crammd5</smtp_authentication></depends>
</smtp_username>
<smtp_password translate="label">
Expand All @@ -153,7 +153,7 @@
<sort_order>26</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>smtp</option><smtp_authentication separator=",">login,plain,crammd5</smtp_authentication></depends>
</smtp_password>
<smtp_host translate="label">
Expand All @@ -162,7 +162,7 @@
<sort_order>29</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>smtp</option></depends>
</smtp_host>
<smtp_port translate="label">
Expand All @@ -171,7 +171,7 @@
<sort_order>32</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>smtp</option></depends>
</smtp_port>
<smtp_ssl translate="label comment">
Expand All @@ -182,7 +182,7 @@
<sort_order>35</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<show_in_store>1</show_in_store>
<depends><option>smtp</option></depends>
</smtp_ssl>

Expand Down

0 comments on commit 56d79c2

Please sign in to comment.