I am customizing my email by writing a block in template file,

in email template

{{block type='core/template' area='frontend' template='email/external/customer.phtml'}}

and template/email/external/customer.phtml is

$fieldsName = Mage::getSingleton('core/session')->getFields();

$message = Mage::getSingleton('core/session')->getMessage();
$emailTemplateData = Mage::getSingleton('core/session')->getEmailTemplateData();
<p style="padding: 5px;"><?php echo $message; ?></p>
<?php if ($emailTemplateData) : ?>
    <table style="width:75%; padding: 5px;">
        <tr style="padding: 5px;">
            <td> <strong><?php echo "Field"; ?></strong></td>
            <td> <strong><?php echo "Data"; ?></strong></td>
        <?php foreach ($emailTemplateData as $key => $value): ?>

                <td> <?php echo $fieldsName[$key] . ":"; ?></td>
                <td> <?php echo $value; ?></td>

        <?php endforeach; ?>


<?php endif; ?>

and email is being send like

public function sendEmail($subject, $fieldsName, $message, $emailTemplateData) {
        //Want to send these not this way

        $emailTemplateVariables = array();
        $emailTemplateCode = "External Customer Creation"; //Email Template Code
        $emailTemplate = Mage::getModel('core/email_template')->loadByCode($emailTemplateCode);
        $emailSubject = $subject; //Email Subject
        $emailTemplateVariables['templateMessage'] = ""; //Variables for Confirmation Mail. 

        $senderName = Mage::getStoreConfig('trans_email/ident_general/name'); //Getting the Store E-Mail Sender Name.
        $senderEmail = Mage::getStoreConfig('trans_email/ident_general/email'); //Getting the Store General E-Mail.
        //Appending the Custom Variables to Template.

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

        //Sending email to listed id under 
        //"Admin >> System >> Configuration >> Customer >> Customer Configuration >> External Source Customer Creation >> Confirmation email recipients"
        $emailIds = Mage::getStoreConfig('customer/external_source_customer/confirmation_email_to');
        $toEmailList = explode(",", $emailIds);

        foreach ($toEmailList as $toEmail) {

            $mail = Mage::getModel('core/email')

            try {
            } catch (Exception $e) {

And my email template is like...

ul {
    margin-left: 0;
    padding-left: 14px;

<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
    <td align="center" valign="top" style="padding:20px 0 20px 0">
        <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;font-size:12px;">
            <!-- [ header starts here] -->
                <td colspan='2' valign="top"><a href="{{store url=""}}"><img src="{{skin url="images/abc-logo-225x83.png" _area="frontend" _package="default" _theme="abc"}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
            <!-- [ middle starts here] -->
                <td valign="top" colspan='2'>
                    <p style="line-height:16px; margin:0;">
                     {{block type='core/template' area='frontend' mydata=$fieldsName template='email/external/customer.phtml'}}
                <td colspan='2' bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you, <strong>abc Team</strong></p></center></td>

This is working fine. But this not a good way, as you can see I am passing data to session to get in my phtml file, what I want is that is there a way pass this data to phtml file in a proper way.

1 Answer 1


In Your block write like this and

{{block type='core/template' area='frontend' mydata="1" template='email/external/customer.phtml'}}

Your phtml you get this data like this

echo $this->mydata;

please check and let me know it help you or not.

  • didn't get you, you mean {{block type='core/template' area='frontend' mydata=$fieldsName template='email/external/customer.phtml'}} and $this->mydata; will give me what i want? Commented Sep 8, 2016 at 19:33
  • try this will definitely will work Commented Sep 9, 2016 at 2:41
  • ok going to try it, did I need to set it in "sendEmail" or not Commented Sep 9, 2016 at 4:19
  • This is not working Commented Sep 9, 2016 at 4:29
  • @Qaisar Satti.. Commented Sep 9, 2016 at 4:38

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.