首页>Magento>source

我尝试添加交易邮件,但我没有收到任何邮件

$template_id = 'my_custom_email';
    // Who were sending to...
    $email_to = '[email protected]';
    $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

<[email protected] My custom email template @-->
<[email protected]
{"store url=\"\"":"Store Url",
"var logo_url":"Email Logo Image Url",
"var logo_alt":"Email Logo Image Alt",
"var data.custom_variable":"Custom variable"}
@-->
<[email protected]
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>

这是什么问题

最新回答
  • 2019-8-16
    1 #

    你的模板文件名不正确

    更改此

    <file>custome_email.html</file>
    

    <file>my_custom_email.html</file>
    

  • magento 2.1:必需的状态不在Checkout中工作
  • magento2:Magento 2目录价格规则适用于special_price