Does someone know how do I get the id of an email by name set on backend? I have an email created in backend in transactional emails that I want to send it programatically, but the id of it may differ depending on the instance that I'm on (local, live, stage), and I can only provide the same name for it. I have this:


And I need to find out $templateId and I only know that I saved the mail with name "Tests".

  • Why not configure it in the backend as every other mail too? Commented Feb 22, 2015 at 22:27

1 Answer 1


Try calling: Mage::getModel('core/email_template')->loadByCode('Tests') if Tests is the name of the template you set up.

After that you can set the sender name, sender email etc and send it. Here is some sample code:

     $emailTemplate = Mage::getModel('core/email_template');
                    $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
                    $mail = Mage::getModel('core/email')

         try {
                } catch (Exception $error) {
                    Mage::log($error->getMessage(), null, 'auto_order_emails.log');

$mailTemplate in above sample would be 'Tests' from your example.

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.