2014-04-24 1 views
-1

맞춤 모듈 용 이메일 템플릿을 만들었습니다.Magento 코어/email_template_mailer가 맞춤 모듈 용 메일을 보내지 않음

그 경우에는 core/email_template_mailer (Mage::getModel('core/email_template_mailer');)을 사용하고 있으며 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> 

좋아하는 config.xml 파일에서 템플릿 HTML을 정의합니다.

그 경우 core/email_template_mailer (Mage :: getModel ('core/email_template_mailer');)를 사용하고 있으며 html 템플릿이 있습니다. 그러나 작동하지 않습니다. 여기

가 config.xml 파일에서 템플릿 HTML을 정의

vendor_account_new.html HTML

그리고 메일이 코드를 보내 새로운 계정 인

$vednor=Mage::getModel('vendor/vendor')->load(66); 
    /** @var $mailer Mage_Core_Model_Email_Template_Mailer */ 
      $mailer = Mage::getModel('core/email_template_mailer'); 
      $emailInfo = Mage::getModel('core/email_info'); 
      $emailInfo->addTo($vednor->getEmail(), $vednor->getName()); 
      $mailer->addEmailInfo($emailInfo); 

      // Set all required params and send emails 
      $mailer->setSender('[email protected]'); 
      $mailer->setStoreId(1); 
      $mailer->setTemplateId('vendor_create_account_email_template'); 
      $mailer->setTemplateParams(array('vendor' => $vednor)); 
      $mailer->send(); 

그리고 vendor_account_new.html의 코드는 문제가 무엇인지 하나가 말해 줄 수

<[email protected] Welcome, {{var vendor.name}}! @--> 
<[email protected] 
{"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"} 
@--> 

<[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;"> 
        <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> 

, ...

답변

0

코드로 오랫동안 싸운 후에 나는 solution을 가지고 있습니다. 주요 문제는 code format and it variable system format입니다. 여기

코드와 단계 :

1 단계 : 현재 상점 ID를 가져옵니다.

$storeId=Mage::app()->getStore()->getId(); 

2 단계 : Sender() parameters 배열 형식이어야합니다 array('email'=>(string) $senderemail,'name'=> (string)'$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) '[email protected]','name'=> (string)'Bal ta')); 
      $mailer->setStoreId($storeId); 
      $mailer->setTemplateId((string) 'vendor_account_create_template'); 
      $mailer->setTemplateParams(array('vendor'=>$Vendor)); 
      $mailer->send(); 
1

사용하는 것입니다이 ..

에 대한 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> 

에 대한 controller

try{ 
//load the custom template to the email 
    $emailTemplate = Mage::getModel('core/email_template')->loadDefault('custom_payment'); 
// it depends on the template variables 
    $emailTemplateVariables = array(); 
    $emailTemplateVariables['order_id'] = $data['order']; 
    $emailTemplateVariables['logo_url'] = $logo; 
    $emailTemplateVariables['customer_name'] = $firstname; 
    $emailTemplateVariables['customer_info'] = $firstname.' '.$lastname; 
    $emailTemplateVariables['shipment_url'] = $data['link']; 
    $emailTemplateVariables['store_name'] = Mage::app()->getStore()->getName(); 

    $emailTemplate->setSenderName($senderName); 
    $emailTemplate->setSenderEmail($senderEmail); 
    $emailTemplate->setType('html'); 
    $emailTemplate->setTemplateSubject($firstname.' you forgot to choose shipping options for your product'); 
    $emailTemplate->send($data['email'], $firstname . $lastname, $emailTemplateVariables); 
    $linker = mysql_real_escape_string(base64_encode($data['link'])); //print_r($linker);exit; 
    $model = Mage::getModel('paymentlink/paymentlink') 
    ->setRelatedOrderid($data['order']) 
    ->setCustEmail($data['email']) 
    ->setPrice($data['price']) 
    ->setReceived(0) 
    ->setLink($linker) 
    ->setLinkId($data['key']) 
    ->save(); 
Mage::getSingleton('adminhtml/session')->addSuccess("Link has been Generated successfully & Email has been sent ! </br>".$data['link'].""); 
    } 
    catch (Exception $e) { 
     $errorMessage = $e->getMessage(); 
     Mage::getSingleton('adminhtml/session')->addError("We cannot send generated link . There must be some error occurs."); 
     return $errorMessage; 
    } 
+0

kingshuk, 난이 안하에 대해 khow입니다/email_template_mailer. –

+0

왜 core_template_mailer를 고수하고 싶습니까? 거기에 대한 구체적인 이유가 있습니다 .BTW 참고하시기 바랍니다. 나 또한 html로 사용자 정의 이메일 템플릿을 사용하여 여기에 맞춤 모듈을 사용했습니다. –

+0

Magento는 해당 기능을 사용하고 있습니다. 왜 내가 그것을 사용할 수 없습니까 ??? –