之前介绍了一下稍微复杂一点的 magento email:发送自定义邮件
但是呢,当我们对magento email机制有一定的了解之后,便可以在模块中使用自定义邮件模板快速实现发送邮件功能!
登入后台system->Transactional Emails,单击右上角Add New Template,选择一个已存在的template,单击Load TemplateINSERT INTO `magento`.`core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES (NULL, 'default', '0', 'customer/test/test_template', '27');path可以自己定义,但是自己要记得我们这里随便定义为customer/test/test_template,value的值是27,就是上面刚刚我们新加的那条记录的ID。
define('EMAIL_TEMPLATE', "customer/test/test_template"); $mailSubject = 'my subject'; $sender = Array('name' => 'Customer Service', 'email' => '[email protected]'); $to = array('[email protected]'); /*This is optional*/ $storeId = Mage::app()->getStore()->getId(); $template = Mage::getStoreConfig(EMAIL_TEMPLATE); $mailConfirm = Mage::getModel('core/email_template'); $translate = Mage::getSingleton('core/translate'); $mailConfirm ->setTemplateSubject($mailSubject) ->sendTransactional($template, $sender, $to, '', Array('subject'=>$mailSubject,'customer'=>$customer),$storeId); $translate->setTranslateInline(true);
本文地址:http://blog.csdn.net/shangxiaoxue/article/details/7835895