3

I have created a custom transactional email for contact us and applied this on the admin contact. The emails are successfully received on our test email. However, the email contains all the html codes. I have tried my best to solved this but I can't do it. I also tries to research for similar problem but no luck. I am using magento 1.9.1.0 version.

this is my transactional email code

<!doctype html >
<html>
<head>
<meta http-equiv="Content-Type"  content="text/html; charset=UTF-8" />
<title>Hey</tile>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>
            <tr>Name:</tr>
            <tr>{{var data.name}}</tr>
        </td>
    </tr>
</table>
</body>
</html>

this is what we received in the email

<!doctype html >
<html>
<head>
<meta http-equiv="Content-Type"  content="text/html; charset=UTF-8" />
<title>Hey</tile>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>
            <tr>Name:</tr>
            <tr>Simon</tr>
        </td>
    </tr>
</table>
</body>
</html>

How do I solve this issue? Is there any settings on the admin that I did not enabled?

I hope you can help me.

Thanks

2

Maybe late for an answer...

Make sure your config.xml contains such a line : <type>html</type>.

   <template>
        <email>
            <Your_node_here translate="label" module="your_module_name">
                <label>Your Label here</label>
                <file>dir/file.html</file>
                <type>html</type>
            </Your_node_here>
        </email>
    </template>

Hope this helps...

1

Don't include <head> section.

<!doctype html >
<html>
<head>
<meta http-equiv="Content-Type"  content="text/html; charset=UTF-8" />
<title>Hey</tile>
</head>

That's all I could see default transactional email not having them. For transactional email magento by default adds <head> for you. So whatever you add in template will be treated as email content.

Update

Replace your code with this:

<body>
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>
            <tr>Name:</tr>
            <tr>Simon</tr>
        </td>
    </tr>
</table>
</body>

You need tag to tell browser this is html.

Update 2

Replace above code in your_email_template.html as well as in transactional email template (System > Transactional Email) if you have created.

  • Thanks for your reply. I have tried to remove those tag and retain the table tag and other html tag however I still receive it as it is. Still no change. – Rodge Jul 3 '15 at 3:01
  • Have you deleted </html> at the end too? All you keeping is <body> to </body> only. – Adarsh Khatri Jul 3 '15 at 3:02
  • Yes, actually my first code starts on the table tag only. I tried to add the html, head and meta hoping it will work. But still no luck. It's like the system interpret the code as all pure text. – Rodge Jul 3 '15 at 3:08
  • You have to wrap your table inside <body></body>, that's why it is not getting called as html. – Adarsh Khatri Jul 3 '15 at 3:16
  • I tried to wrapped the table inside body tag however still the same. I suspect that this is not about the tags but I suspect that there something else to be configure in the system. the problem is that I don't know where – Rodge Jul 3 '15 at 3:22
1

Following are steps to create custom Template emails. Make sure you have followed them:

  1. Go to System > Transaction Emails
  2. Click on Add new Template
  3. Under "Load default template" which is first tab, for "Template" select "Contact Form" and Click on "Load Template"

enter image description here

This should load a default template

  1. Now add your custom details under tab "Template Information": for "Template Content" you can fill
<body> <table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td>
            <tr>Name:</tr>
            <tr>Simon</tr>
        </td>
    </tr> </table> </body>

Click on "Preview Template" and make sure the template looks like how you want it to look. enter image description here

Click on "Save Template" once satisfied. This should give you whats desired.

UPDATE: IF this isnt working: @Rodge maybe give this a try:

Copy: app/code/core/Mage/Adminhtml/Block/System/Email/Template/preview.php

To: app/code/local/Mage/Adminhtml/Block/System/Email/Template/preview.php

Comment (Line:63):

//$template->setTemplateText( $filter->filter($template->getTemplateText()) );

Test this for Preview Transaction Emails in admin panel, and see if this works.

  • Hello Joshua. When I click preview it display all the tags same as in email. – Rodge Jul 3 '15 at 7:44
  • @Rodge I updated my answer. Let me know if that works. – Ajay Bisht Jul 3 '15 at 7:56
  • I can't find the line of codes that you have mentioned. – Rodge Jul 3 '15 at 8:04
  • Line no 63: $template->setTemplateText( $filter->filter($template->getTemplateText()) ); – Ajay Bisht Jul 3 '15 at 8:11
  • Sorry for my late reply. I tried to comment out line 63 but still preview doesn't display what I want. Also, I received on my email all my codes/tags – Rodge Jul 3 '15 at 23:26

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.