I recently discovered this problem while using Webform and HTML Mail module. I've put thank-you letter into Webform which was equal to something like this:

<h1 style="padding:10px; color:#234456; font:12px Arial, Helvetica, sans-serif;">Thank you for your letter!</h1>
Thank you for your letter dude. We will get back to you shortly.

With enabled option to convert new lines to paragraphs in HTML Mail (basic filter format), it resulted in the next code in actual letter:

<h1 style="padding:10px; color:#234456; font:12px Arial,<br/>
Helvetica, sans-serif;">Thank you for your letter!</h1>
<p>Thank you for your letter dude. We will get back to
<br/>you shortly.</p>

As you see, it breaked the style attribute.

First, I thought it's problem of HTML Mail, but when I built full picture I found that it's not. Here's how mails is being built currently:

1. Webform triggers drupal_mail() and passes the message to it. In hook_mail, it performs drupal_wrap_mail() to the message.
2. After that, any other modules like HTML Mail implement hook_mail_later() and do some stuff to the message. In our case, as the message is already wrapped, it puts line breaks in wrong places.
3. Drupal runs it's own drupal_wrap_mail() just before to send the letter.

So, as you see, webform does extra wrapping, which is 1) useless because Drupal runs it in any case 2) harms alter results of other modules.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

neochief’s picture

quicksketch’s picture

Thanks, I'll take a look at this next time I'm reviewing Webform patches.

quicksketch’s picture

Status: Needs review » Fixed

Thanks, Apple's Mail.app hides the normal text wrapping when it renders (making it look unwrapped), but double-wrapping it makes look like a normally wrapped bit of text. The whole thing threw me off a little bit. This patch looks great and works as advertised, committed to both branches.

neochief’s picture

Thanks!

Status: Fixed » Closed (fixed)

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