Custom email sending in magento custom module

前端 未结 3 1879
后悔当初
后悔当初 2021-02-02 17:10

I am working on a module that will send an email after 7 days of order completion. I\'m stuck on sending emails. I can see the email template in transactional emails drop down i

3条回答
  •  失恋的感觉
    2021-02-02 17:56

     $emailTemplate = Mage::getModel('core/email_template')->loadDefault('recurring_order_email_template');
    
    //Getting the Store E-Mail Sender Name.
    $senderName = Mage::getStoreConfig('trans_email/ident_general/name');
    
    //Getting the Store General E-Mail.
    $senderEmail = Mage::getStoreConfig('trans_email/ident_general/email');
    
    //Variables for Confirmation Mail.
    $emailTemplateVariables = array();
    $emailTemplateVariables['name'] = $customerName;
    $emailTemplateVariables['email'] = $customerEmail;
    
    //Appending the Custom Variables to Template.
    $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
    
    //Sending E-Mail to Customers.
    $mail = Mage::getModel('core/email')
     ->setToName($senderName)
     ->setToEmail($customerEmail)
     ->setBody($processedTemplate)
     ->setSubject('Subject :')
     ->setFromEmail($senderEmail)
     ->setFromName($senderName)
     ->setType('html');
     try{
     //Confimation E-Mail Send
     $mail->send();
     }
     catch(Exception $error)
     {
     Mage::getSingleton('core/session')->addError($error->getMessage());
     return false;
     }
    

提交回复
热议问题