Magento – {{inlinecss file=”email-inline.css”}} not working in custom email template

emailmagento-1.9

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('test@gmail.com')
        ->setFrom('test1@gmail.com', "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?

Best Answer

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
                ]);
Related Topic