Magento Sending Custom Email

01 / Apr / 2013 by amatya 3 comments

By default magento sends emails on its certain events like customer registration, order creation etc. Also you can customize or change these email templates from admin > System > Transaction Email. What if you want add your own custom email template or if you want to add email feature in your custom module. This blog helps you in achieving this. Following are steps :

First of all create your email template test.html under following directory.

app\locale\en_US\template\email. Where en_US is your default language pack. You can replace it with your own.

<!–@subject Custom Email for {{var customVariable}} @–>
{"store url=\"\"":"Store Url",
"var logo_url":"Email Logo Image Url",
"var logo_alt":"Email Logo Image Alt",
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;">
Hello {{var custName}}<br>
Thank you. Your logo path is {{var logo_url}}

<!–@subject : In this tag you can define subject line of your email.
<!–@vars : In vars section you can define your custom variable.
<!–@styles : In this tag section you can add custom style for your email template.
{{var custName}} : By using {{var custName}} you can add your custom variable in your email template.

Now add following code in your module’s config.xml file’s global node.

<label>Test Email</label>

Now clear magento cache and go to admin > Transactional Email > Add New Template. From here you can load your cuatom email template

Add the following code in your controller’s action from where you want to send your email.

$templateId = 25 //your email template id;
$sender = Array(‘name’ => ‘Sender’s Name’,
’email’ => ‘’);
$email = ‘’;
$emaiName = ‘Sender’s Name’;
$vars = Array();
$vars = Array(‘customVariable’=>$yourCustomVarialbe,
$storeId = Mage::app()->getStore()->getId();
$translate = Mage::getSingleton(‘core/translate’);
->sendTransactional($templateId, $sender, $email, $emailName, $vars, $storeId);

That’s it. Hope this will help you 🙂

Amatya Trivedi


comments (3)

  1. trekking company nepal himalayatrekservices

    I enjoy what you guys are usually up too. This sort of clever work and reporting!
    Keep up the excellent works guys I’ve added you guys to my own blogroll.

  2. Blogger Banua

    Thanks a lot for sharing this with all of us you really recognise what you are speaking about! Bookmarked. Please additionally consult with my web site =). We could have a hyperlink exchange agreement among us


Leave a Reply

Your email address will not be published. Required fields are marked *