How can I create transactional email templates via an install/upgrade script? I need them populated in Transactional Emails rather than having email templates available in the app/locale folder.

2 Answers 2


In a situation like this it's generally useful to follow the logic of the corresponding admin user action, which posts to Mage_Adminhtml_System_Email_TemplateController::saveAction():


if (!$template->getId()) {

if ($request->getParam('_change_type_flag')) {


You can essentially do the same in your setup script, with the obvious difference being that instead of POST params accessed via a request object you are creating your own array directly in the code.


To have a clear answer, here is the installation code I usually use to create a transactional email :


$installer = $this;


$code = 'My Mail Title';
$subject = '{{var store.getFrontendName()}}- Mail subject';
$text = 'Content of my mail in HTML format';
$styles = 'Specific style for the mail';

$template = Mage::getModel('adminhtml/email_template');




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.