Create custom e-mail template in magento

I hope you are aware with the system.xml file in magento so we will not go deep in to it.just add below code to your system.xml file to add select box for choose our custom template.

<email_template translate="label">
<label>Email Template (Sender Notification)</label>

The next step is to add an html-template of the letter. /app/locale/en_US/template/email/contact_sender_notification.html

<!--@subject My Email Subject Subject @-->
<!--@vars {"store url=\"\"":"Store Url", "var logo_url":"Email Logo Image Url", "var logo_alt":"Email Logo Image Alt", "htmlescape var=$" : "Email sender contact form" } @-->
<!--@styles body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; } @-->

<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
<td align="center" valign="top" style="padding:20px 0 20px 0">
            <!-- [ header starts here] -->
<table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<td valign="top">
                        <a href="{{store url=""}}" style="color:#1E7EC8;"><img src="{{var logo_url}}" alt="{{var logo_alt}}" border="0"/></a></td>
<!-- [ middle starts here] -->
<td valign="top">
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear {{htmlescape var=$}},</h1>
Some text</td>
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;">

Thank you again, <strong>{{var store.getFrontendName()}}</strong>

IMPORTANT NOTE :: On the above section you have notice commented code it is not actually commented.

But it use internally in magento to setup subject and var.
If you forgot to define subject it will send mail and raise exceptions in log file.

After adding the code (see above) we will declare the template in the configuration file and will set the template as default in Email Template (Sender Notification) app/code/local/namespace/module/etc/config.xml

               <contacts_sender_notification_email_template translate="label" module="{justmodulenameonly}">
                   <label>Contact Sender Notification</label>

IMPORTANT NOTE :: in the above config.xml file. “contacts_sender_notification_email_template” is the combination of your{section_group_field} of your system.xml file(Please take care of this otherwise it will not reflect on your configuration).

Now you can send mail using this template.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s