Hey,

Before I enable this module (fresh install of Drupal 6.20, nothing but the default modules on), I get this as a registration email.

rickman,

Thank you for registering at devel6. You may now log in to http://devel6/user using the following username and password:

username: rickman
password: eGcGn4M3Ro

You may also log in by clicking on this link or copying and pasting it in your browser:

http://devel6/user/reset/21/1303514266/bf7f459e41aeb19bd3e84d6163cb7f86

This is a one-time login, so it can be used only once.

After logging in, you will be redirected to http://devel6/user/21/edit so you can change your password.


--  devel6 team

But if I simply turn on the module, the regular line breaks are now ignored and it makes this garbled mess.

rickman, Thank you for registering at devel6. You may now log in to
http://devel6/user using the following username and password: username:
rickman password: M5x96J7yMJ You may also log in by clicking on this link or
copying and pasting it in your browser:
http://devel6/user/reset/22/1303514346/1a42857f64f2982b9f5c0b02a701db70 This
is a one-time login, so it can be used only once. After logging in, you will
be redirected to http://devel6/user/22/edit so you can change your password.
-- devel6 team

I've tried playing with the short list of settings at admin/settings/mailsystem, but I only can choose between default and testing. Testing clearly just hides the email so that's not a solution.

I'm not turning on HTML email at this point. But even turning that on doesn't help.

I'm marking this as 'major' as it's a deal breaker for now.

Comments

rickmanelius’s picture

This seems to be the culprit.

  public function format(array $message) {
    // Join the body array into one string.
    if (is_array($message['body'])) {
      $message['body'] = implode("\n\n", $message['body']);
    }
    // Convert any HTML to plain-text.
    $message['body'] = drupal_html_to_text($message['body']);
    // Wrap the mail body for sending.
    $message['body'] = drupal_wrap_mail($message['body']);
    return $message;
  }

If I comment out $message['body'] = drupal_html_to_text($message['body']); I can at least get the proper line breaks. I realize this isn't ideal, so I'm not going to do it. But it that drupal_html_to_text function is removing the line breaks in the default user registration message. So simply turning on this module (without html email) will remove the line breaks.

rickmanelius’s picture

Next followup.
If your turn on the HTML mail module, it will work if you turn on the full html input format for anonymous users. If you don't have that enabled, it will go back to a single line.

I actually don't like this setup... because it prevents sending a rich text email to a user without giving them rich text input format capabilities on the front end (comments, etc). So is it possible to remove that restriction and allow the outgoing emails to format with Full HTML even if that user type does not have that capability?

pillarsdotnet’s picture

Title: Mail System format() method uses drupal_html_to_text() which strips linefeeds from input. » Formatting borked just by enabling the module.

Testing to confirm what you describe... Yup. The drupal_html_to_text() function is broken, as described here:

#299138: Improve \Drupal\Core\Utility\Mail::htmlToText()

I suppose I should supply a copy of the patched version with d6 Mail System. (patching...) Okay; fixed in 6.x-2.3 release.

By the way, you will have exactly the same problem if and when you upgrade to Drupal-7, unless #299138 gets resolved first.

Rolled a new release of HTML Mail to use mailsystem_html_to_text() instead of drupal_html_to_text(), at least until issue #299138 gets resolved.

@#2 -- I'm not sure what you want here. It sounds like you want the end-user to type in plain text and the mail system to somehow convert that to HTML. If you just want to preserve line breaks, add the standard Line break converter to your input filter. For more sophisticated text-to-html conversion, try using Markdown or BBcode.

pillarsdotnet’s picture

Title: Formatting borked just by enabling the module. » Mail System format() method uses drupal_html_to_text() which strips linefeeds from input.
Version: 6.x-2.2 » 6.x-2.3
Status: Active » Fixed
Heine’s picture

Title: Formatting borked just by enabling the module. » Mail System format() method uses drupal_html_to_text() which strips linefeeds from input.

#299138: Improve \Drupal\Core\Utility\Mail::htmlToText() is about D7's (and D8's) drupal_html_to_text.

D6 behaviour is by design; whitespace in HTML must be collapsed. See #298708-12: drupal_html_to_text() removes line endings.

pillarsdotnet’s picture

@Heine -- Are you saying that the DefaultMailSystem::format() method is broken because it blindly applies drupal_html_to_text() to all input?

If so, have you submitted a bug report?

Or perhaps you are claiming that the d6 and d7 versions of drupal_html_to_text() are somehow completely different despite sharing identical doxygen headers?

If so, have you submitted a bug report?

Heine’s picture

I'm saying that D6 behaviour is by design.

pillarsdotnet’s picture

Then I am saying that the design is faulty and should be corrected. See http://drupal.org/node/299138#comment-4384420

rickmanelius’s picture

@#3
I'm really talking about system emails. Right now, when the system send out an email (e.g. user registration confirmation w/new username and password), it will be a collapsed single line of text UNLESS anonymous users are allowed to access the full html input filter. So if the system is preparing the message, it should not be restricted by a user's access to format filters!

Also, the reason why I agree with you in saying this design is faulty: if someone is to switch on the HTML mail module right now, they are in for a serious surprise as it's going to be this compressed plain text. It took me 3 hours of navigating in and out of the modules and GUI options to figure it out. There will probably be a lot of forum questions until (out of the box) the HTML toggle is on and working!

I'm not saying you're not doing an amazing job here. But I was a might surprised when I went through my last drush upgrade! Now, I have simply disabled HTML mail altogether so that the emails are at least working...

pillarsdotnet’s picture

As I said, this is fixed in latest version of both Mail System and HTML Mail. See the diff.

rickmanelius’s picture

Hey Pillars.

Apologies. I didn't keep up with the entire thread. I'll be sure to check it out. Thanks for the very speedy response :)

Status: Fixed » Closed (fixed)

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