1

I am trying to send custom email with some variables in it, but don't know what I am doing wrong in it here is my code :

    $emailTemplate  = Mage::getModel('core/email_template');
    $emailTemplate->loadByCode('custom_email_template');
    //$emailTemplate->loadDefault('custom_email_template');
    //$emailTemplate->load($templateId);
    /* tried all of the above to load template but same results */
    $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/email'));
    $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/name'));


    $processedTemplate = $emailTemplate->getProcessedTemplate($templateVariables);

    try {
        $emailTemplate->send($rec_email, $rec_name, $templateVariables);
    }
    catch(Exception $ex) {
        echo Mage::getSingleton('core/session')->addError($this->__($ex->getMessage()));
    }

I added the template from Magento admin panel transactional emails, haven't created any html file for template.

Email is getting sent but variables are shown as

{{ var sender_name }}

{{ var rcver_name }}

{{ var pr_name }}

{{ var order_number }} 

Please give me an idea of what I am doing wrong.

2

Remove start and end spaces from the template variables like

{{var sender_name}}

{{var rcver_name}}

{{var pr_name}}

{{var order_number}} 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.