Custom email sending in magento custom module

前端 未结 3 1952
后悔当初
后悔当初 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:46

    Change your etc/config.xml code to below:

    
    

    Change your controller code to below:

    $emailTemplate = Mage::getModel('core/email_template')
                ->loadDefault('recurring_order_email_template');
    
        $emailTemplateVariables = array();
        $emailTemplateVariables['var1'] = 'var1 value';
        $emailTemplateVariables['var2'] = 'var 2 value';
        $emailTemplateVariables['var3'] = 'var 3 value';
    
       $emailTemplate->getProcessedTemplate($emailTemplateVariables);
    
       $emailTemplate->setSenderName('sender name');
       $emailTemplate->setSenderEmail('sender@test.com');
        try {
       $emailTemplate->send($recipientEmail, $senderName, $emailTemplateVariables);
        } catch (Exception $e) {
            echo $e->getMessage();
        } 
    

    Change your $recipientEmail, $senderName & $emailTemplateVariables as per your need.

    To load a email template, you must specifiy the tag name after

    
    

    that you provided in the config.xml

提交回复
热议问题