1

Drupal adds line breaks after a width of 77 in the function wrapMailLine() of the class core/lib/Drupal/Core/Mail/MailFormatHelper.php.

What is the reason for that?

If you open the mail in a small viewport like on a phone, e.g. the line breaks after 50 chars and then again after 27 chars. This behavior is undesired.

1
  • 1
    I believe this has to do with some (old) web standard for plaintext emails. You can send HTML emails instead by installing Mailsystem and Swiftmailer. Commented Aug 29, 2018 at 19:36

1 Answer 1

0

Because of RFC2822 (Internet Message Format), section 2.1.1 (Line Length Limits):

There are two limits that this standard places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

Why they chose 77 and not 78 for Drupal, I don't know, but I'd bet my house the decision was originally based on that standard.

2
  • Thank you! This clarifies the reason for this function. That means I have to patch it out because there will be no change in the Drupal Core for that because of this RFC?
    – Leduec
    Commented Aug 29, 2018 at 14:33
  • Difficult to say really - I think it’s quite likely the rfc will remain relevant, and very likely that Drupal will continue to conform to it while it is. Beyond that it’s guess work! You might not have to patch anything, D8 is pretty pluggable.
    – Clive
    Commented Aug 29, 2018 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.