B-219 Sec-55 Noida, India
+918010221733

Send Email programmatically using magento

<?php
include “app/Mage.php”;
Mage::app();
error_reporting(E_ALL);
ini_set(“display_errors”, 1);

// The Id you just marked from the transactional email template id
$templateId = 1;

// Define the sender, here we query Magento default email (in the configuration)
// For customer support email, use : ‘trans_email/ident_support/…’
$sender = Array(‘name’ => Mage::getStoreConfig(‘trans_email/ident_general/name’),
                ’email’ => Mage::getStoreConfig(‘trans_email/ident_general/email’));

// Set you store
// This information may be taken from the current logged in user
$store = Mage::app()->getStore();

// In this array, you set the variables you use in your template
$vars = Array(‘my_var’ => $my_var,
              ‘another_var’ => 12);

// You don’t care about this…       
$translate  = Mage::getSingleton(‘core/translate’);

// Send your email
Mage::getModel(‘core/email_template’)->sendTransactional($templateId,
                                                         $sender,
                                                         ‘[email protected]’,
                                                         ‘Recipient Name’,
                                                         $vars,
                                                         $store->getId());

// You don’t care as well       
$translate->setTranslateInline(true);
?>

(Visited 96 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.