I created a subtheme for my mail theme. The generated HTML without any input filters active looks like this:

<!DOCTYPE html>
<html  lang="de" dir="ltr">

<head>
  <meta charset="utf-8" />
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
  <title>corporate_dev has forwarded a page to you from clients | clients</title>

  <style>@import url("http://clients.example.ch/modules/system/system.base.css?lzdmkd");
@import url("http://clients.example.ch/modules/system/system.messages.css?lzdmkd");
@import url("http://clients.example.ch/modules/system/system.theme.css?lzdmkd");</style>
<style>@import url("http://clients.example.ch/sites/all/modules/simplenews/simplenews.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/date/date_api/date.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/date/date_popup/themes/datepicker.1.7.css?lzdmkd");
@import url("http://clients.example.ch/modules/field/theme/field.css?lzdmkd");
@import url("http://clients.example.ch/modules/node/node.css?lzdmkd");
@import url("http://clients.example.ch/modules/user/user.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/views/css/views.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/extlink/extlink.css?lzdmkd");</style>
<style>@import url("http://clients.example.ch/sites/all/modules/ctools/css/ctools.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/ctools/css/modal.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/modal_forms/css/modal_forms_popup.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/panels/css/panels.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/modules/views_slideshow/views_slideshow.css?lzdmkd");</style>
<style>@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/fonts.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/html-reset.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/layout-fixed.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/page-backgrounds.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/tabs.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/pages.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/blocks.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/navigation.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/views-styles.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/panels-styles.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/nodes.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/comments.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/forms.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/fields.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/print.css?lzdmkd");
@import url("http://clients.example.ch/sites/all/themes/clients_mail/css/custom.css?lzdmkd");</style>
  </head>
<body class="html not-front not-logged-in no-sidebars page-echo i18n-de section-echo" >
      
<div id="page-wrapper"><div id="page">

  CONTENT
  
</div></div><!-- /#page, /#page-wrapper -->

  </body>
</html>

As soon as I activate one input filter it looks like this:

<div><div><div>
<div><div></div></div>
<div><div><div><div>
                  
                  CONTENT
                  
</div></div></div></div>
</div></div></div>
</html>

What could be the problem?

Comments

pablov2’s picture

Lukas von Blarer are you using Emogrifier with HMTL Mail? I have the same issue.

luksak’s picture

Yes, I do. But it doesn't matter what filter I apply. All of them cause the same error. I switched to MIME Mail by now...

jmonma’s picture

This seems like a potential duplicate of the issue posted for emogrifier, but if Lukas is right then HTML Mail is probably the right place for this issue: http://drupal.org/node/1336106

I am also experiencing a similar issue with the emogrifier post-filter enabled. When I debug, it seems like HTML Mail isn't properly passing the themed output to the filters.

pillarsdotnet’s picture

I believe that HTML Mail is discarding the HEAD portion of the document and only passing the BODY portion to filters.

j0rd’s picture

@pillarsdotnet regarding #4.

I believe that HTML Mail is actually putting the entire htmlmail.tpl.php through the input filter and this causes many problems for me. I'm using the latest 6.x-2.64

I've created a new input filter and only added the "Turn new lines into <br />" filter. It seems that HTML Mail pushes the entire template through the filter, instead of just the $body, or other variables.

So a template like this


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body { background: #ddd; }
</style>
</head>

<body class="htmlmail">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td valign="top" align="center">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td valign="top" class="htmlmail-body">

          <table width="800" border="0" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size: 13px; background: white;"><tr><td>
Heres some body
Heres some more        
          </td></tr></table>
          </td>
        </tr>
     </table>
   </td>
 </tr>
</table>
</body>
</html>

end up looking like this


<p><html><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></p>
<style type="text/css">
body { background: #ddd; }
</style><p></head></p>
<p><body class="htmlmail"></p>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td valign="top" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="htmlmail-body">
<table width="800" border="0" align="center" style="font-family:Arial,  
Helvetica, sans-serif; font-size: 13px; background: white;">
<tr>
<td>
Heres some body<br />
Heres some more
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p></body><br />
</html></p>

Notice all the weird P and BR tags all over the place.

Also in the past I've seen problems with import filters and @import I believe. I can not recall where through. Also I would think perhaps the original problem of the poster might be related to filtering HTML (and not having the proper tags enabled). So the extra HTML is getting removed. Again though, if this only filtered over the body, then we wouldn't have a problem.

j0rd’s picture

So, I've tracked down to where this is happening.

First lets start with these assumptions:

  1. You create a new filter called "HTML Email Filter" and add the "Turn new lines into
    " filter to it.
  2. You are passing a "body" which contains "Hello\nWorld" (where \n is a new line)
  3. You are using a custom htmlmail.tpl.php which wraps your body around some HTML. In this template you have new lines

Example htmlmail.tpl.php


<html>
  <head>
    <style>
      body {background: black; color: white;}
    </style>
  </head>

  <body>
    <h1>Some title</h1>
    <p>Some more header data</p>

    $BODY

    <p>SOme footer data</p>

  </body>
</html>

Now in htmlmail/htmlmail.mail.inc `function format();` you have this line:
$body = theme('htmlmail', $message); which initialized body with the original body + htmlmail template.

Then if we go down a little further, there's

      if ($filter = variable_get('htmlmail_postfilter', FILTER_FORMAT_DEFAULT)) {                         
        //watchdog('debug', "BEFORE: " . dprint_r(array('body' => $body), TRUE));                           
        $filtered_body = check_markup($body, $filter, FALSE);                                             
        //watchdog('debug', "AFTER: " . dprint_r(array('body' => $body), TRUE));          
        if ($filtered_body) {                                                                             
          $body = $filtered_body;                                                                         
        }      
        ...
     }

This snippet runs the entire original body + htmlmail template through the input filter. This is the bug (or desired behavior?)

Either way, for me, this won't work. I simply need body run through the input filter. I could see how perhaps running other variables through the input filter may be important, but I believe the template itself should be left alone.

I'll submit a patch following this, which will simply input filter the $message['body'] variable, but since I'm not that familiar with the module, I'm not sure if that's the desired behavior.

neochief’s picture

Had the same issue as j0rd in #6. If you use any post filter in module options, all of your theming might suffer from it. I have no idea is it by design, but it looks like input formats are suppose to be run before theming happens, but not after.

I end-up with filtering body in my theme and disabling the postfilter option.

peterx’s picture

A quick question about filter sequence. Where is Emogrifier in the text format filter processing order? Does it work the same if Emogrifier is last in the list?

pillarsdotnet’s picture

Yeah, Emogrifier should probably come last.

peterx’s picture

Pathologic puts the following note on the text type config page. What happens when you use all the filter options recommended for HTML mail? They will all want to be last.
In most cases, Pathologic should be the last filter in the “Filter processing order” list.

pillarsdotnet’s picture

Emogrifier doesn't affect link hrefs, and pathologic doesn't affect style info, so their order relative to each other doesn't matter.

maico de jong’s picture

While sending the 'request new password' mail through HTML Mail i also encounterd the same problem. Using HTML Mail + Emogrofier(Filter) + Convert to line breaks(filter).

After putting some html tags in the request new password message(admin/config/people/accounts) everything seems to work fine. So in my case the problem only exists when sending some plain text.

In that case: Maybe the problem comes from Drupal Core input format as explained in: http://drupal.org/node/1095838 ?

salvis’s picture

Status: Active » Closed (outdated)