2

I try to add Transaction mail but i am not getting any mail

$template_id = 'my_custom_email';
    // Who were sending to...
    $email_to = 'mymail@gmail.com';
    $customer_name   = $name;
    // Load our template by template_id
    $email_template  = Mage::getModel('core/email_template')->loadDefault($template_id);

    $custom_variable = 'my custom variable for my custom eamil template';
    // Here is where we can define custom variables to go in our email template!
    $email_template_variables = array(
        'custom_variable' => $custom_variable
        // Other variables for our email template.
    );

    // In my case I am using the Store Name as sender name here.
    $sender_name = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_STORE_STORE_NAME);
    // In my case I am using the general store contact here as the sender email.
    $sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
    $email_template->setSenderName($sender_name);
    $email_template->setSenderEmail($sender_email); 

    //Send the email!
    $email_template->send($email_to, $customer_name, $email_template_variables);

Config.xml

<template>
            <email>

                <my_custom_email>
                    <label>Custom email</label>
                    <file>custome_email.html</file>
                    <type>html</type>
                </my_custom_email>
            </email>
        </template>

custome_email.html

<!--@subject My custom email template @-->
<!--@vars
{"store url=\"\"":"Store Url",
"var logo_url":"Email Logo Image Url",
"var logo_alt":"Email Logo Image Alt",
"var data.custom_variable":"Custom variable"}
@-->

<!--@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;">
                        <!-- [ Header starts here] -->
                        <tr>
                            <td valign="top">
                                <a href="{{store url=""}}" style="color:#1E7EC8;"><img src="{{var logo_url}}" alt="{{var logo_alt}}" border="0"/></a>
                            </td>
                        </tr>
                        <!-- [ Header ends here] -->
                        <!-- [ middle starts here] -->
                        <tr>
                            <td valign="top">
                                <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">This is my custom email template</h1>
                                <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;"><strong>My custom variable is :</strong> {{var custom_variable}}</p>
                            </td>
                        </tr>
                        <!-- [middle ends here]-->
                        <!-- [Footer content starts here] -->
                        <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>
                        <!-- [Footer content ends here] -->
                    </table>
                </td>
            </tr>
        </table>
    </div>
</body>

what's wrong on this

11
  • fir check <template> is inside the <global> tag and check admin panel email template is listed or not.. – Qaisar Satti Mar 16 '16 at 7:35
  • In side global tag only i add this code existing module is it any pronlem – Magento 2 Mar 16 '16 at 7:36
  • no that is not problem the email defined inside the global tag check that it is inside or not? – Qaisar Satti Mar 16 '16 at 7:43
  • It's inside global tag only also path this is the path of html file app/locale/en_US/template/email/my_custom_email.html – Magento 2 Mar 16 '16 at 7:45
  • go admin panel in system-> transactional email and add new check in dropdown your template is listed or not – Qaisar Satti Mar 16 '16 at 7:57
1

your template file name is not correct

change this

<file>custome_email.html</file>

to

<file>my_custom_email.html</file>
10
  • Now i am not getting mail – Magento 2 Mar 16 '16 at 9:24
  • load in admin panel it is working – Qaisar Satti Mar 16 '16 at 9:25
  • ya in admin panel its working. – Magento 2 Mar 16 '16 at 9:26
  • I don't know why i am getting two time mail – Magento 2 Mar 16 '16 at 9:28
  • How to get COntact number here any idea – Magento 2 Mar 16 '16 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.