Follow these rules and your mail templates will most likely not be considered as spam: 1. Always wrap the content in … 2. Remove all empty lines 3. Remove all font size definitions, like font:11px/1.35em 4. Avoid spam words such…
Loading a mail template by its name (Magento 1)
Use the below code to load a Magento transaction mail template by its name:
1 2 |
$templateId = Mage::getModel('core/email_template')->loadByCode('<name>')->getTemplateId(); $template = Mage::getModel('core/email_template')->load($templateId); |
Getting mail template content by name (Magento 1)
Use the following code to get a mail templates content by its name:
1 2 3 |
$mailTemplate = Mage::getModel('core/email_template'); $templateByName = $mailTemplate->loadbyCode($templateName); $text = $templateByName ->getData('template_text'); |
Getting mail template content by id (Magento 1)
Use the following code to get a mail templates content by its id:
1 2 3 |
$mailTemplate = Mage::getModel('core/email_template'); $template = $mailTemplate->load($templateId); $text = $template->getData('template_text'); |
Changing mail template content by id programmatically (Magento 1)
To change the content of a Magento mail template by its id, use the following code:
1 2 3 4 |
$mailTemplate = Mage::getModel('core/email_template'); $feedbackTemplate = $mailTemplate->load($templateId); $feedbackTemplate->setData('template_text', 'new text goes here'); $feedbackTemplate->save(); |