Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento core/email\u template\u mailer不发送自定义模块的邮件_Magento_Templates_Magento 1.7_Mailer_Email Templates - Fatal编程技术网

Magento core/email\u template\u mailer不发送自定义模块的邮件

Magento core/email\u template\u mailer不发送自定义模块的邮件,magento,templates,magento-1.7,mailer,email-templates,Magento,Templates,Magento 1.7,Mailer,Email Templates,我已经为自定义模块创建了一个电子邮件模板 在这种情况下,它有使用core/email\u template\u mailer(Mage::getModel('core/email\u template\u mailer');)和html模板 这里定义config.xml中的模板html <template> <email> <vendor_create_account_email_template transl

我已经为自定义模块创建了一个电子邮件模板

在这种情况下,它有使用
core/email\u template\u mailer
Mage::getModel('core/email\u template\u mailer');
)和html模板

这里定义config.xml中的模板html

<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>
而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>

用这个

对于
config.xml

<template>
            <email>
                <custom_payment  module="paymentlink">
                    <label>Payment Link</label>
                    <file>custom_payment.html</file>  <!-- this specifies the path where the custom template is located -->
                    <type>html</type>
                </custom_payment>
            </email>
        </template>

经过与代码的长期斗争,我得到了
解决方案
。主要问题是
代码格式和it变量系统格式

这里是代码和步骤:

步骤1:获取当前商店id

 $storeId=Mage::app()->getStore()->getId();
步骤2:
Sender()参数
应采用数组格式
array('email'=>(字符串)$senderemail,'name'=>(字符串)$sendername)

完整代码是

 $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) 'dev.amitbera@gmail.com','name'=> (string)'Bal ta'));
            $mailer->setStoreId($storeId);
            $mailer->setTemplateId((string) 'vendor_account_create_template');
            $mailer->setTemplateParams(array('vendor'=>$Vendor));
            $mailer->send();

kingshuk,我知道这件事。但是,我想用core/email\u template\u mailer发送邮件。你为什么要坚持使用core\u template\u mailer??有什么具体的原因吗..顺便说一句,我在这里也使用了自定义模块和一个自定义电子邮件模板,该模板也是html。如果你有问题,你可以很容易地切换到其他模型..不要坚持/爱上一个特定的模型:P如果你能做到这一点,那么你就不应该浪费时间在core_template_mailerKingshuk上,我在做兰德。那我为什么要离开它??
 $storeId=Mage::app()->getStore()->getId();
 $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) 'dev.amitbera@gmail.com','name'=> (string)'Bal ta'));
            $mailer->setStoreId($storeId);
            $mailer->setTemplateId((string) 'vendor_account_create_template');
            $mailer->setTemplateParams(array('vendor'=>$Vendor));
            $mailer->send();