Hey guys,

I have a little problem where when the subject line is more than 77 characters. it will try to put a new line and continue the text but because of a particular line in mimemail_prepare_message($message) function (line:530).

$subject = str_replace(array(" \n", "\n"), '', trim(drupal_html_to_text($subject)));

The "/n" gets removed and i end up with something like this.

"12 January 2014" becomes "12January 2014"

drupal_html_to_text(); calls drupal_wrap_mail(); calls _drupal_wrap_mail_line(); this is where the "\n" gets added.

I hope all this makes sense. Thank you in advance.

CommentFileSizeAuthor
#4 mimemail-2185909.patch1.43 KBcyrus_bt5

Comments

cyrus_bt5’s picture

Issue summary: View changes
sgabe’s picture

That line was added by #1605230: Extra space in subject caused by wordwrap, so this needs more investigation. Another possibly related issue is #380334: Extra space in Subject and Reply-to headers.

cyrus_bt5’s picture

Hi sgabe, thanks for getting back to me so quickly. I have had a look at the other two issue queues and created my own patch from all the comments. Everything is working as it should now. Cheers.

Ref #1605230 , #380334

cyrus_bt5’s picture

StatusFileSize
new1.43 KB
sgabe’s picture

Title: Email subjects with more than 77 characters. » Extra space in long header fields
Status: Active » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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

knalstaaf’s picture

I'm still having this issue in 7.x-1.0-beta4.

gaëlg’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Closed (fixed) » Active

Yes, I face this too. I looked further and here's what happen to me.

In mimemail_prepare_message(), the $subject before the call to drupal_html_to_text() is:

[MadeInScop] Nouveau sujet "Recrutement Assistant(e) Marketing en CDI - Poste 
à pourvoir immédiatement"

(Note the space after "Poste" and before the new line)

It goes into drupal_html_to_text() and stays as-is (in $chunk) until the call to:

$output .= drupal_wrap_mail($chunk, implode('', $indent)) . MAIL_LINE_ENDINGS;

Then, in drupal_wrap_mail(), it stays as-is until the call to:

    // Remove trailing spaces to make existing breaks hard, but leave signature
    // marker untouched (RFC 3676, Section 4.3).
    $text = preg_replace('/(?(?<!^--) +\n|  +\n)/m', "\n", $text);

After this, $text is:

[MadeInScop] Nouveau sujet "Recrutement Assistant(e) Marketing en CDI - Poste
à pourvoir immédiatement"

(The trailing space is removed)

So that finally, in mimemail_prepare_message(), at this call:
$subject = str_replace(array("\n"), '', trim(drupal_html_to_text($subject)));
... $subject ends up to:
[MadeInScop] Nouveau sujet "Recrutement Assistant(e) Marketing en CDI - Posteà pourvoir immédiatement"
(A space is missing between "Poste" and "à")

I don't yet know where the code should not behave as it does.

gaëlg’s picture

Status: Active » Closed (fixed)

Actually the problem is before: the subject shouldn't have this newline when entering mimemail_prepare_message(). It's Mail Edit which truncates it by calling drupal_html_to_text() in _mail_edit_mail_alter().

gaëlg’s picture

knalstaaf’s picture

Status: Closed (fixed) » Active

Please don't get too jumpy when it comes to closing topics. I'd like to hear confirmation of others first, especially from the maintainers.

salvis’s picture

Status: Active » Fixed

I've just published Mail Editor 7.x-1.2 including the patch mentioned above.

Status: Fixed » Closed (fixed)

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