1

I copied email template from one of default magento email. and i am getting everything in email but css not being loaded in email.

<template>
    <email>
        <test_email_template translate="label" module="dio">
            <label>Test Email Template</label>
            <file>test/test_email_template.html</file>
            <type>html</type>
        </test_email_template>
    </email>
</template>

below is controller code for calling email template.

$emailTemplate = Mage::getModel('core/email_template')->loadDefault('test_email_template');
$template_variables = array(
    'name' =>  'helllo',
);

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

try {
    $z_mail = new Zend_Mail('utf-8');
    $z_mail->setBodyHtml($processedTemplate)
        ->setSubject('Test')
        ->addTo('[email protected]')
        ->setFrom('[email protected]', "tesing");
    $z_mail->send();
} catch (Exception $e) {
}

and this is my test_email_template.html file code.

{{template config_path="design/email/header"}}
{{inlinecss file="email-inline.css"}}

<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>{{var name}}</td>
    </tr>
</table>
{{template config_path="design/email/footer"}}

everything is working fine and i am getting email but css is not loading in email. is there any solution for that?

2 Answers 2

2

I have fixed that issue, We need to set design config after loading the email template.

$emailTemplate = Mage::getModel('core/email_template')->loadDefault('send_do_shipment_email');
                $emailTemplate->setDesignConfig([
                    'area' => 'frontend',
                    'store' => $storeId
                ]);
1
  • Please specify where you have added this.
    – Max
    Dec 8, 2017 at 17:08
0

Try this:

Go to system->configuration->General->Design->Transactional emails then add your email-inline.css.

Non-inline CSS File(s) : email-non-inline.css,email-inline.css

1

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.