How to add email template and send email in Magento

  • magento send email template
  • magento send email
  • magento email attachment
  • Mage::getModel(core/email_template)
  • magento email templates
  • Mage::getModel(\core/email_template\)

Well, this is quite a popular task for every Magento site. And you can found many tutorials for this which show you how to create and add Magento email template via XML file. Non prescription Viagra in USA has changed the intimate life of so many men! However I’m sure that many people are wondering about Transactions Emails under Magento -> Configuration. Why don’t we use it? And how can we use it?

Here I will explain for you. Basically you can use either email template defined via XML file or stored in database (added via Transactions Emails). And we use same way to send email with these templates. Here is how you can setup code for sending email

This product is just great. ! Discuss your general health status with your doctor to ensure that you are healthy enough to engage in sexual activity.

$storeId = Mage::app()->getStore()->getId();
$templateId = 'catalog_giftrequest_email_template';//here you can use template id defined in XML or you can use template ID in database (would be 1,2,3,4 .....etc)
$mailSubject = 'A new gift request received';

$sender = array('name' => $from,
'email' => $from);
$email = $to;

$name = '';

$mailTemplate = Mage::getModel('core/email_template');

$mailTemplate->setTemplateSubject($mailSubject)
->sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);

Following is how you can define/add templates via XML file
1. Create the HTML Template – The email template directory is located in app/locale/en_US/template/email . The key here is that the {{var sample}} is the syntax for adding variables to the email template. If you need more samples you can take a look some of the sample templates there.

sampleEmail.html

Today’s product of the day is {{var sample}}. Please visit our store for more details

I have been using this product for years. I have tried others but have not found anything that works better for me. ? Sixty-three percent, 74%, and 82% of the patients on 25 mg, 50 mg and 100 mg of our medications, respectively, reported an improvement in their health.

2. Create XML definitions and references to the HTML Template – The sendTransactional method allows you to pass an integer for the id if you’ve added the template via the admin console and would like to use the core_email_template table. However it’s considered best practice to follow the process we’ve laid out and create your template separately and configure them via XML.

Add your Template definitions to your modules config.xml between the tags

In the same config.xml file, add to a reference to the template definition right above the closing tag

And in the case, you want to put email template in database (and edit via admin)
Go to Magento Admin -> Configuration -> Transactions Emails -> Add Template

Comments Closed