Skip to content

Commit

Permalink
mailgun
Browse files Browse the repository at this point in the history
  • Loading branch information
adam ling committed Jul 11, 2018
1 parent 7ec489f commit ea97e37
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/code/local/Aschroder/SMTPPro/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,7 @@ public function getGoogleAppsEmailTransport($id = null)
return $this->getTransport($id);
}

public function getMailgunTransport($id = null){
return Mage::getModel("smtppro/transports_mailgun")->getTransport($id);
}
}
11 changes: 9 additions & 2 deletions app/code/local/Aschroder/SMTPPro/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

class Aschroder_SMTPPro_Model_Observer extends Varien_Object {

protected $_mailgun = array('sales_email_order_template','sales_email_order_guest_template');
public function cleanOldLogs(Varien_Event_Observer $observer)
{
$lifetime = Mage::helper('smtppro')->getLogLifetimeDays();
Expand Down Expand Up @@ -58,7 +58,14 @@ public function beforeSend($observer) {
*/
public function beforeSendTemplate($observer) {
Mage::helper('smtppro')->log($observer->getEvent()->getMail());
$observer->getEvent()->getTransport()->setTransport(Mage::helper('smtppro')->getTransport());
//$observer->getEvent()->getTransport()->setTransport(Mage::helper('smtppro')->getTransport());
$template_id = $observer->getEvent()->getTemplate()->getId();
if(in_array($template_id,$this->_mailgun)){
$transport = Mage::helper('smtppro')->getMailgunTransport();
}else{
$transport = Mage::helper('smtppro')->getTransport();
}
$observer->getEvent()->getTransport()->setTransport($transport);
}

public function beforeSendQueue($observer) {
Expand Down
31 changes: 31 additions & 0 deletions app/code/local/Aschroder/SMTPPro/Model/Transports/Mailgun.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* @author Ashley Schroder (aschroder.com)
* @copyright Copyright (c) 2014 Ashley Schroder
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Aschroder_SMTPPro_Model_Transports_Mailgun extends Aschroder_SMTPPro_Model_Transports_Basesmtp {

public function getName($storeId) {
return "Mailgun SMTP";
}
public function getEmail($storeId) {
return '[email protected]';
}
public function getPassword($storeId) {
return '9050ba3b340298feb3237322285379d1-0470a1f7-af605aa2';
}
public function getHost($storeId) {
return 'smtp.mailgun.org';
}
public function getPort($storeId) {
return '587';
}
public function getAuth($storeId) {
return 'login';
}
public function getSsl($storeId) {
return 'tls';
}
}

0 comments on commit ea97e37

Please sign in to comment.