0

I have created an email template in the custom module, This is the code I have used to add the template.

    <template>
        <email>
            <spritzrequestquotation_email_template translate="label" module="sprrequestquotation">
                <label>Request Quotation Email</label>
                <file>requestquotation_email_template.html</file>
                <type>html</type>
            </sprrequestquotation_email_template>
        </email>
    </template>

This is my module folder structure. app/local/Spr/RequestQuotation/

I have created an email template (requestquotation_email_template.html).

Controller code calling the template and sending mail. I am getting an email but mail body is empty.

$emailTemplate = Mage::getModel('core/email_template')->loadDefault('requestquotation_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(
        'firstname' => 'John',
        'lastname'  => 'D.'
    );
    $emailTemplateVariables['name'] = $fullName;
    $emailTemplateVariables['email'] = $email;

    //Appending the Custom Variables to Template.
    $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);

    //Sending E-Mail to Customers.
    $mail = Mage::getModel('core/email')
     ->setToName($senderName)
     ->setToEmail($senderEmail)
     ->setBody($processedTemplate)
     ->setSubject('Request A Quotation')
     ->setFromEmail($senderEmail)
     ->setFromName($senderName)
     ->setType('html');

$mail->send();

1 Answer 1

1

try with below code

        $storeId = 1;
        $customerName = 'john';

        $mailer = Mage::getModel('core/email_template_mailer');

        $emailInfo = Mage::getModel('core/email_info');
        $emailInfo->addTo($to, $customerName);
        $mailer->addEmailInfo($emailInfo);

        $mailer->setSender(Mage::getStoreConfig('<yourpath>', $storeId));
        $mailer->setStoreId($storeId);
        $mailer->setTemplateId('<yourtemlateid>');

// in case you would like to pass variable data to your template html
        $mailer->setTemplateParams(array(
            'test' => 'test',

        )
        );

        $mailer->send();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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