Drupal Version: 7.32
Printer, email and PDF versions: 7.x-2.0
Mail module: SMTP Authentication Support 7.x-1.0
Browser: Chrome
Mail Tool: gmail

As reported in this issue, when sending an email, the recipient receives the raw html generated by the print.tpl.php template. I took the html in the email and saved it in a file called test.html. When I opened the file using my browser, it looked fine. But within gmail, the html is not rendered. The SMTP module configuration has a checkbox to Allow to send e-mails formated as Html. This is checked. We do send some webform emails in html format.

I also created a print--mail.tpl.php template and it is being used. I don't know if I'm expected to modify this template and if so, can you please provide some guidance?

Thank you. This module is very helpful.

CommentFileSizeAuthor
#3 sharebyemail-plaintohtml.patch391 bytesbenJBmC
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ann b created an issue. See original summary.

ann b’s picture

Title: Email Not Working (not using mimemail) » Mail Not Working With SMTP Module

This issue is a duplicate of Send email breaks with SMTP module. That issue will not be fixed in the SMTP Module.

The work-around below worked for me:

*

function mymodule_form_print_mail_form_alter(&$form, &$form_state) {

   $form['#submit'][0] = 'mymodule_print_mail_form_submit';

}
function mymodule_print_mail_form_submit($form, &$form_state) {

   // copy print_mail_form_submit($form, &$form_state) contents here, and change this line:

   $ret = drupal_mail('mymodule', $print_mail_send_option_default, $to, language_default(), $params, $from);

}
function mymodule_mail($key, &$message, $params) {

   // copy print_mail_mail($key, &$message, $params) contents here, and change the following:

   case 'sendpage':
      $message['body'][] = $params['body'];
      $message['headers']['Content-Type'] = 'text/html; charset=utf-8';
      break;

}
benJBmC’s picture

FileSize
391 bytes

Right ann b, that's a solution but you will have to update your copies of code if you update print module.
Problem comes from check_plain() function in file print_mail.module.
Need to change :

$message['body'][] = check_plain($params['body']);

to

$message['body'][] = $params['body'];

See patch attached.