I'm using this module and am having some formatting issues with the HTML newsletters. I looked at the HTML source of the messages and saw two opening <bode> tags:

    </style>
  </head>
  <body id="mimemail-body">
    <div id="center">
      <div id="main">
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <html>
          <head>
            <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
              <title>
                : test</title>
            </head>
            <body bgcolor="#ffffff">
              <style type="text/css">
                <!-- -->
              </style>
              <table class="simplenews-template-background" width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0">
                <tr>

Is this a Simplenews Template issue or a Mimemail issue? Anyone else seeing this HTML document inside and HTML document issue?

Comments

Z2222’s picture

Typo above.. should say:
"two opening <body> tags"

Z2222’s picture

Is this part of the code creating a duplicate HTML document within Mimemail's HTML document?

function theme_simplenews_template_mail_content($node, $newsletter_name, $issue_title, $style, $bgcolor) {
  return <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>$newsletter_name: $issue_title</title>
</head>

Here it is the HTML output in the newsletter. I'm using a mail.css file in my template to remove my theme's CSS. Notice that there are two HTML documents there:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--/* This UN-formats the HTML emails by removing all CSS */ -->
</style>
</head>
<body id="mimemail-body">
<div id="center">
<div id="main">

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
 <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
 <title>
: test again</title>
 </head>
 <body bgcolor="#ffffff">
 <style type="text/css">
 <!-- -->
 </style>
 <table class="simplenews-template-background" width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0">
Alex72RM’s picture

Priority: Normal » Critical

With this problem the module is not usable (most of customized css is not rendered).

Surely better 1.1 version.

stevekerouac’s picture

Subscribe

TBarregren’s picture

Assigned: Unassigned » TBarregren

I can confirm the bug. It is due to changes in how the content is passed between the three modules Simplenews_template, Simplenews and MimeMail. I'll investigate it further.

keesje’s picture

I can confirm this too.
Simplenews_template, Simplenews and MimeMail are all adding HTML to the message.

Please note that simplenews now has a templating method of its own by using the PHP theme engine.
I had to override a theme_ hook in mimemail to prevent it from adding HTML, deinstall simplenews_template and go with the simplenews templates to get smooth HTML without strange linebreaks or duplicate tags.

I would like to use simplenews_template still..

keesje’s picture

Oh, and disable base64 encoding for the message body in mimemail. Its in an issue somewhere here. This makes the message code readable for debugging.

TBarregren’s picture

Status: Active » Fixed

See commit #168052. Will be inclued in the upcoming 5.x-1.3.

Alex72RM’s picture

Version: 5.x-1.2 » 5.x-1.4-beta1
Priority: Critical » Normal

Hi,

many thanks for this new module version.

I noted however that the row:

<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

from simplenews_template.tpl.php is stripped out from the sent newsletter (the html code has always a void row in place between <head> and <title> tags).

TBarregren’s picture

The <meta>-element is included in the HTML sent to the MTA, and it is visible in Thunderbird. I therefore believe it is your e-mail client that filters it out.

But it is not a problem since Mime Mail sets the Content-Type to text/plain; utf-8. Actually, I am not sure if any mail client respects <meta>-element in the HTML.

Alex72RM’s picture

Hi again and thanks for your quick response,

I've investigated a little more this type of issue.

A lot of help has been given by print_mail (print submodule) that builds an html email without mimemail module.

I noticed that regarding headers information, print_mail sets up an header array variable:

$headers = array('Content-Type' => 'text/html; charset=utf-8');

and then sends emails with a drupal_mail command:

drupal_mail('print_mail_sendpage', $to, $params['subject'], $params['body'], $from, $headers);

On the contrary, basing the work on mimemail, simplenews_template sends the meta tag from a pre-defined html code to a mimemail function:

mimemail($from, $mail->to, $mail->subject, $mail->body, $plain_text_only, $headers, $plain_text_body, array(), 'simplenews-send-mail');

Mimemail sends a different type of content (plain or html) basing on user settings. What is the module output when the user is anonymous and then hasn't decided for an email setting or another (html/plain)? I found that with this condition, two versions of email are sent, melt into a single email (!):

First part: Content-Type: text/plain; charset=utf-8: all the content is plain, with a css preamble (ugly and unreadable)
Second part: Content-Type: text/html; charset=utf-8: html email correctly rendered

I think that the best approach is within print_mail (I know, we lose plain email... but nowadays who reads emails with a plain reader?)

Alessandro

Alex72RM’s picture

Version: 5.x-1.4-beta1 » 5.x-1.4-beta2
Status: Fixed » Active

I noticed that this issue had "fixed" status.

On the contrary, discussions show that it's an active one.

TBarregren’s picture

Status: Active » Fixed

@Alex72RM:

Could you please explain in what respect the bug is not fixed. The bug report talks about two <body>-tags, and as far as I can tell this bug is fixed. If you still see two <body>-tags, don't hesitate to reopen this issue again to give details on how to recreate the bug.

If you want to replace Mime Mail with an alternative, you should not discuss that in a bug report, but open a feature request. Since it is the Simplenews module that depends on Mime Mail to send HTML-email, you should open that feature request on that modules issue queue and not here.

Mimemail sends a different type of content (plain or html) basing on user settings. What is the module output when the user is anonymous and then hasn't decided for an email setting or another (html/plain)? I found that with this condition, two versions of email are sent, melt into a single email (!):

First part: Content-Type: text/plain; charset=utf-8: all the content is plain, with a css preamble (ugly and unreadable)
Second part: Content-Type: text/html; charset=utf-8: html email correctly rendered

This is how it is suppose to work. A client who request plain text should not get HTML-email, and all others should have a multipart e-mail.

Again, if you don't like this, you should either open a feature request on the Mime Mail issue queue, requesting this behavior to change, or on the Simplenews issue queue, requesting Mime Mail to be replaced.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kenorb’s picture

Patch for 6.x version: #373915: Two <html> tags