发送交易电子邮件magento

时间:2014-04-15 15:04:27

标签: magento email transactions subscription

我尝试在magento中创建订阅订单但是没有发送任何内容时发送确认电子邮件。 我知道电子邮件配置很好,因为当我购买普通产品时,我确实收到了电子邮件。 我在System -> Transactional Emails上创建了一个模板,在id=12上创建了模板,然后在class AW_Sarp2_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage上的代码上调用了发送子电子邮件方法,但它从不发送任何电子邮件

 class AW_Sarp2_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
public function saveOrder()
{   Mage::log("checkout/onepage",null,"onepageemail.log");
    $isQuoteHasSubscriptionProduct = Mage::helper('aw_sarp2/quote')->isQuoteHasSubscriptionProduct(
        $this->getQuote()
    );
    if (!$isQuoteHasSubscriptionProduct) //HERE I ASK IF IS A SUBSCRIBE PRODUCT {Mage::log("checkout/onepage34",null,"onepageemail.log");
        return parent::saveOrder();
    }
    $this->validate();
    $isNewCustomer = false;
    switch ($this->getCheckoutMethod()) {
        case self::METHOD_GUEST:Mage::log("checkout/onepage40",null,"onepageemail.log");
            $this->_prepareGuestQuote();
            break;
        case self::METHOD_REGISTER:Mage::log("checkout/onepage43",null,"onepageemail.log");
            $this->_prepareNewCustomerQuote();
            $isNewCustomer = true;
            break;
        default:Mage::log("checkout/onepage47",null,"onepageemail.log");
            $this->_prepareCustomerQuote();
            break;
    }

    if ($this->getQuote()->getCustomerId()) {Mage::log("checkout/onepage52",null,"onepageemail.log");
        $this->getQuote()->getCustomer()->save();
    }
    #AW_SARP2 override start
    $service = Mage::getModel('aw_sarp2/sales_service_profile', $this->getQuote());Mage::log("checkout/onepage56",null,"onepageemail.log");
    $service->submitProfile();Mage::log("checkout/onepage57",null,"onepageemail.log");
    #AW_SARP2 override end

    $this->getQuote()->save();Mage::log("checkout/onepage60",null,"onepageemail.log");
    if ($isNewCustomer) {Mage::log("checkout/onepage61",null,"onepageemail.log");
        try {
            $this->_involveNewCustomer();Mage::log("checkout/onepage63",null,"onepageemail.log");
        } catch (Exception $e) {
            Mage::logException($e);
        }
    }

    $this->_checkoutSession->setLastQuoteId($this->getQuote()->getId())
        ->setLastSuccessQuoteId($this->getQuote()->getId())
        ->clearHelperData();Mage::log("checkout/onepage71",null,"onepageemail.log");
    // add recurring profiles information to the session
    $profiles = $service->getRecurringPaymentProfiles();Mage::log("checkout/onepage73",null,"onepageemail.log");
    if ($profiles) {Mage::log("checkout/onepage74",null,"onepageemail.log");
        $ids = array();
        foreach ($profiles as $profile) {
            $ids[] = $profile->getId();
        }Mage::log("checkout/onepage78",null,"onepageemail.log");
        $this->sendSubscribeEmail2();Mage::log("checkout/onepage79",null,"onepageemail.log");

        $this->_checkoutSession->setLastRecurringProfileIds($ids);
        Mage::log("checkout/onepage82",null,"onepageemail.log");
    }
    return $this;
}

public function sendSubscribeEmail2(){ //HERE I TRY TO SEND THE EMAIL

    $templateId = 12;
    // Set sender information
    $senderName = Mage::getStoreConfig('trans_email/ident_support/name');
    $senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
    $sender = array('name' => $senderName,
    'email' => $senderEmail);
    // Set recepient information
    $recepientEmail = 'minorandres@gmail.com';
    $recepientName = 'Test Test';
    // Get Store ID
    $storeId = Mage::app()->getStore()->getId();
    // Set variables that can be used in email template
    $vars = array('customerName' => 'test',
    'customerEmail' => 'minorandres@gmail.com');
    $translate = Mage::getSingleton('core/translate');Mage::log("checkout/onepage103",null,"onepageemail.log");
    // Send Transactional Email
    Mage::getModel('core/email_template')
    ->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);Mage::log("checkout/onepage106",null,"onepageemail.log");
    if (!Mage::getModel('core/email_template')->getSentSuccess()) {
        Mage::log("EXCEPTION!!!! =( checkout/onepage107",null,"onepageemail.log");
    }

xml文件中有什么我必须做的或其他地方吗?请帮帮我

1 个答案:

答案 0 :(得分:0)

由于我正在处理订阅产品,因此它们由不同的SMTP提供商处理,在例外​​情况下我得到了错误" Mandril无法发送电子邮件"类似的东西然后我去管理面板和系统>交易电子邮件有一个名为mandril的子标签配置该工具并在mandril上创建一个帐户,然后我将由mandril指示的API密钥放入系统>配置> mandril(在左侧) )。