send Magento email by templatee

$templateId = "Fav Email";

$emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateId);

$userName='wang';
$productName="test 123";
$receiveEmail='xiaoming@leeroy.ca';
$receiveName=$userName;
$vars = array('user_name' => $userName, 'product_name' => $productName,'message'=>'test message');
$emailTemplate->getProcessedTemplate($vars);
var_dump($emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', 1)));
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', 1));
var_dump($emailTemplate->send($receiveEmail,$receiveName, $vars));

Leave a Comment