Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

email

magento

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 the e-mail?

Thanks.

like image 792
user649650 Avatar asked Jan 30 '26 05:01

user649650


1 Answers

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
        )
    );   
like image 177
Joe Mastey Avatar answered Jan 31 '26 21:01

Joe Mastey