Magento 2 Certified Developer | StackExchange Moderator | Amit Bera

Magento 2 eCommerce Developement | Magento Web developement

  • Home
  • Magento 2
  • Magento
  • General
  • YouTube
  • Server
  • About Amit Bera
  • Contact
  • Home
  • Magento 2
  • Magento
  • General
  • YouTube
  • Server
  • About Amit Bera
  • Contact

No Widgets found in the Sidebar Alt!

No Widgets found in the Sidebar Alt!

Magento

magento Custom Email with html email template

May 24, 2014 /

magento Custom Email with html email template

Last week ,i was working on magento custom email template where i have create a html template and send mail using Mage::getModel('core/email_template_mailer');

For implement Magento Custom Email with html template.

Please follow the below steps:

step1:first define html template at your config.xml using below code:

 

<template>
            <email>
                <vendor_create_account_email_template translate="label" module="vendor">
                    <label>New account</label>
                    <file>vendor_account_new.html</file>
                    <type>html</type>
                </vendor_create_account_email_template>
             </email>   
     </template>

Here vendor_create_account_email_template is always unique id of html template
and  vendor_account_new.html is html file for custom mail which located at app/locale/Your_store_Language/template/email

 

Step2: Now we will run the email template using  below code

$storeId=Mage::app()->getStore()->getId();
$Vendor=Mage::getModel('vendor/vendor')->load(57);
 
/** @var $mailer Mage_Core_Model_Email_Template_Mailer */
$mailer = Mage::getModel('core/email_template_mailer');
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo((string)$Vendor->getEmail(),(string) $Vendor->getName());
$mailer->addEmailInfo($emailInfo);
// Set all required params and send emails
$mailer->setSender(array('email'=>(string) '[email protected]','name'=> (string)'Bal ta'));
$mailer->setStoreId($storeId);
$mailer->setTemplateId((string) 'vendor_account_create_template');
$mailer->setTemplateParams(array('vendor'=>$Vendor));
$mailer->send();

Step3: And code of html  which are located in app\locale\your language\template\email\vendor_account_new.html

<!--@subject Welcome, {{var vendor.name}}! @-->
<!--@vars
{"store url=\"\"":"Store Url",
"var logo_url":"Email Logo Image Url",
"htmlescape var=vendor.name":"Customer Name",
"store url=\"customer/account/\"":"Customer Account Url",
"var vendor.email":"Customer Email",
"htmlescape var=$customer.password":"Customer Password"}
@-->
 
<!--@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%">
        <tr>
            <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;">
                    <tr>
                        <td valign="top">
                            <a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
                    </tr>
                <!-- [ middle starts here] -->
                    <tr>
                        <td valign="top">
                            <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear {{htmlescape var=$vendor.name}},</h1>
                            <p style="font-size:12px; line-height:16px; margin:0 0 16px 0;">Welcome to {{var store.getFrontendName()}}. To log in when visiting our site just click <a href="{{store url="customer/account/"}}" style="color:#1E7EC8;">Login</a> or <a href="{{store url="customer/account/"}}" style="color:#1E7EC8;">My Account</a> at the top of every page, and then enter your e-mail address and password.</p>
                            <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">
                                Use the following values when prompted to log in:<br/>
                                <strong>E-mail</strong>: {{var vendor.email}}<br/>
                                <strong>Password</strong>: {{htmlescape var=$vendor.password}}<p>
                            <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">When you log in to your account, you will be able to do the following:</p>
                            <ul style="font-size:12px; line-height:16px; margin:0 0 16px 0; padding:0;">
                                <li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Proceed through checkout faster when making a purchase</li>
                                <li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Check the status of orders</li>
                                <li style="list-style:none inside; padding:0 0 0 10px;">&ndash; View past orders</li>
                                <li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Make changes to your account information</li>
                                <li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Change your password</li>
                                <li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Store alternative addresses (for shipping to multiple family members and friends!)</li>
                            </ul>
                            <p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:{{config path='trans_email/ident_support/email'}}" style="color:#1E7EC8;">{{config path='trans_email/ident_support/email'}}</a> or by phone at {{config path='general/store_information/phone'}}.</p>
                        </td>
                    </tr>
                    <tr>
                        <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
</body>

 

custom emailmagento
By devadmin 0 Comments

Recent Posts

  • Magento2 php8.1 extension install
  • Magento 2 create yes/no product attribute
  • Api search magento using php
  • Magento2 Custom options do not show at Cart
  • Category page NOINDEX,NOFOLLOW when filters applied

Recent Comments

  • URL on Magento2 Checkout shipping address autofill
  • Magento2 programmatically create coupon l- Amit Bera | amitbera.com on How to get magento2 base url
  • Magento2 programmatically create coupon l- Amit Bera | amitbera.com on Magento2 add a cms page link to menu
  • Magento2 Checkout shipping address autofill- Amit Bera | amitbera.com on magento2 get base url and media url and static url

Archives

  • November 2022
  • September 2022
  • August 2022
  • December 2021
  • September 2021
  • April 2019
  • March 2019
  • January 2019
  • April 2018
  • September 2017
  • June 2017
  • October 2016
  • April 2016
  • March 2016
  • February 2016
  • August 2015
  • January 2015
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • December 2013
  • November 2013

Categories

  • General
  • Magento
  • Magento 2
  • Server
  • Uncategorized
  • Weekly Dairy

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Ashe Theme by WP Royal.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok