Is it possible to send an e-mail programmatically in Magento?

后端 未结 2 1753
伪装坚强ぢ
伪装坚强ぢ 2021-01-14 18:42

Is it possible to send an e-mail programmatically in Magento? Maybe from a controller in a custom module, could you get hold of a template, populate its variables, and send

相关标签:
2条回答
  • 2021-01-14 19:23

    It's certainly possible. The email handling in Magento is quite powerful (and can be complex).

    Without knowing exactly what you're trying to achieve, it would be worth you starting off by looking at the Mage_Core_Model_Email_Template class as that drives Magento's email handling.

    0 讨论(0)
  • 2021-01-14 19:29

    Absolutely. Here's an example from the Checkout helper:

    $mailTemplate = Mage::getModel('core/email_template');   
    $template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId()); 
    $mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId()))
        ->sendTransactional(
            $template,
            Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()),
            $recipient['email'],
            $recipient['name'],
            array(
                'reason' => $message,
                ...
                'total' => $total
            )
        );   
    
    0 讨论(0)
提交回复
热议问题