I'm sending rendered table through mail using Mimemail module.
And this table is totally broken, because of hardcoded limit of line width set to 77 chars in _drupal_wrap_mail_line()

Example

This code:

$line = <ul class="links inline"><li class="comment_forbidden first last"></li>

breaking the line to:

$line = "<ul class="links inline"><li\n 
class="comment_forbidden first last"></li>"

Then when filter is activated, function _filter_autop() making another line breaking ("in an intelligent fashion"):

$chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks

this time line looks like:

$line = "<ul class="links inline"><li<br/> class="comment_forbidden first last"></li>"

All this causing unexpected output in mail:

class="comment_forbidden first last">
CommentFileSizeAuthor
#1 mail.inc_.diff600 byteskenorb

Comments

kenorb’s picture

StatusFileSize
new600 bytes

Temporary core patch for my own purpose until proper fix.

damien tournoud’s picture

Status: Active » Postponed (maintainer needs more info)

_drupal_wrap_mail_line() is designed to run last (just before the mail is sent). Running filters after the mail has been wrapped sounds like a bug in the Mimemail module.

kenorb’s picture

I'm not sure if this module solve that issue:
http://drupal.org/project/smartlinebreakconverter

damien tournoud’s picture

Title: wrong line wrapping on drupal_wrap_mail() in mail.inc » Wrong line wrapping on drupal_wrap_mail() in mail.inc
Project: Drupal core » Mime Mail
Version: 6.x-dev » 6.x-1.x-dev
Component: base system » Code

Probably not a core bug.

kenorb’s picture

Title: Wrong line wrapping on drupal_wrap_mail() in mail.inc » wrong line wrapping on drupal_wrap_mail() in mail.inc
Project: Mime Mail » Drupal core
Version: 6.x-1.x-dev » 6.x-dev
Component: Code » base system

Thanks for reply.
I'll make some additional tests.

kenorb’s picture

Project: Drupal core » Mime Mail
Version: 6.x-dev » 6.x-1.x-dev
Component: base system » Code
Status: Postponed (maintainer needs more info) » Active

Sorry, post in the same time revert your changes;)

kenorb’s picture

There could be some conflict if I'm sending rendered node via node_view($node, FALSE, TRUE) through mail?
Some unexpected double calls, rendering, then _drupal_wrap_mail_line could be not run last, arguments which I can't use in this case, or something?

Basically it's my custom defined token (Token) like [my-node], which contain rendered node node_view($node, FALSE, TRUE) which is sent through mail using Actions (Send tokenized e-mail).

kenorb’s picture

Test 1 by sending Newsletter with following content (using Mimemail):

print node_view(node_load(246))

was received properly (where 246 is nid of some node).
OK

Test 2 by sending Newsletter with following token (using Mimemail):

[some-rendered-node]

was received properly.
OK

Test 3
Assigned Tokenized Mail action with '[my-node]' rendered through node_view() on content update.
Mail is broken.
NOT OK

kenorb’s picture

Project: Mime Mail » Drupal core
Version: 6.x-1.x-dev » 6.x-dev
Component: Code » filter.module

Disabling 'Line break converter' from Full HTML fix the problem with broken HTML.
So I think it's rather Filter issue, than Mimemail.
There are already too many issues with Filter, so one more will not make any difference.

kenorb’s picture

Version: 6.x-dev » 6.12
damien tournoud’s picture

Component: filter.module » base system
Category: bug » support
Status: Active » Postponed (maintainer needs more info)

This has nothing to do with the filter system. As I told you already, drupal_wrap_mail() is supposed to be called *after* all filtering has taken place. Please try to find out why it is not the case in your particular use case.

Requalifying as a support request until you have more information.

damien tournoud’s picture

Here is the probable code flow. The mail first get prepared by:

- token_actions_send_email_action()
- drupal_html_to_text()
- drupal_wrap_mail()
- drupal_mail()
- drupal_mail_wrapper()

Then Mime mail does:

- $body = check_markup($body, ...), running the line break converter on an already wrapped mail

Sure, the line break converter could be a lot better... but I have no idea why Mime mail wants to run check_markup() there.

mdupont’s picture

Project: Drupal core » Mime Mail
Version: 6.12 » 6.x-1.x-dev
Component: base system » Code
Status: Postponed (maintainer needs more info) » Active

Mime Mail issue it is, then.

sgabe’s picture

Category: support » bug
Status: Active » Closed (duplicate)

I am marking this as a duplicate of #1128354: Check markup only before wrapping, since there is a patch that addresses this bug, although we need to remove the check_markup() call from drupal_mail_wrapper() too. Please, post any further comments there.