Unwanted line breaks in mail body

I’ve noticed that mail sent from Lucee (4.5.1.023) has line breaks inserted
every 900 or so characters, despite the fact that the preceding block has
multiple CRLFs and is therefore not a continuous line.

I’ve read this Railo ticket https://issues.jboss.org/browse/RAILO-2155
and understand that the Internet Message Format standard prescribes a limit
of 998 characters per line after which mail servers are supposed to add a
line. But that’s not the case here as all of my line lengths are well under
that limit (I’m actually wrapping them at 72 before passing the text to
cfmail)

The deliberate line breaks are all visible in the generated mail, but it
seems they are being ignored and the first 998 characters treated as if it
were a continuous line.

I’ve also tried belt & braces by using the “wraptext” attribute of cfmail,
setting it at 72, with the same result: the wrapping is visible, but the
unwanted break every 900 or so characters keeps being inserted. Specifying
“quoted-printable” as a parameter makes no difference either.

I have tried using two different mail servers with the same result.

Running the same code against ACF using the same mail server does not
result in any extra line breaks.

Here is a test case:

crlf=Chr( 13 ) & Chr( 10 ); lineEndingInABreak="one two three" & crlf; textWithLineBreaks=RepeatString( lineEndingInABreak,140 ); #textWithLineBreaks# #textWithLineBreaks# #textWithLineBreaks#

For me, this generates mail with unwanted line breaks inserted at lines 66
and 132 in the first message. Can anyone confirm this behaviour and/or
point to a workaround?

Cheers
Julian
http://cfsimplicity.com/

Hi Julian,

The underlying problem is here: https://github.com/lucee/Lucee4/blob/master/lucee-java/lucee-core/src/lucee/runtime/net/smtp/StringDataSource.java#L37 https://github.com/lucee/Lucee4/blob/master/lucee-java/lucee-core/src/lucee/runtime/net/smtp/StringDataSource.java#L37
Any html and/or plain text content is converted into a StringDataSource, which in turn does one WordUtils.wrap on the text / html. Unfortunately, the org.apache.commons.lang.WordUtils::wrap function handles the incoming string as one line, regardless of any line break within the string.

A fix could be this: Update StringDataSource.java · lucee/Lucee4@ff5b291 · GitHub https://github.com/lucee/Lucee4/commit/ff5b291bf346fd36b23d30e29d6ab5c48c76e631

I have done a pull request on this change now (Update StringDataSource.java by paulklinkenberg · Pull Request #27 · lucee/Lucee4 · GitHub https://github.com/lucee/Lucee4/pull/27).

Kind regards,

Paul KlinkenbergOp 23 sep. 2015, om 16:23 heeft Julian Halliwell <@Julian_Halliwell> het volgende geschreven:

I’ve noticed that mail sent from Lucee (4.5.1.023) has line breaks inserted every 900 or so characters, despite the fact that the preceding block has multiple CRLFs and is therefore not a continuous line.

I’ve read this Railo ticket https://issues.jboss.org/browse/RAILO-2155 and understand that the Internet Message Format standard prescribes a limit of 998 characters per line after which mail servers are supposed to add a line. But that’s not the case here as all of my line lengths are well under that limit (I’m actually wrapping them at 72 before passing the text to cfmail)

The deliberate line breaks are all visible in the generated mail, but it seems they are being ignored and the first 998 characters treated as if it were a continuous line.

I’ve also tried belt & braces by using the “wraptext” attribute of cfmail, setting it at 72, with the same result: the wrapping is visible, but the unwanted break every 900 or so characters keeps being inserted. Specifying “quoted-printable” as a parameter makes no difference either.

I have tried using two different mail servers with the same result.

Running the same code against ACF using the same mail server does not result in any extra line breaks.

Here is a test case:

crlf=Chr( 13 ) & Chr( 10 ); lineEndingInABreak="one two three" & crlf; textWithLineBreaks=RepeatString( lineEndingInABreak,140 ); #textWithLineBreaks# #textWithLineBreaks# #textWithLineBreaks#

For me, this generates mail with unwanted line breaks inserted at lines 66 and 132 in the first message. Can anyone confirm this behaviour and/or point to a workaround?

Cheers
Julian
http://cfsimplicity.com/


See Lucee at CFCamp Oct 22 & 23 2015 @ Munich Airport, Germany - Get your ticket NOW - http://www.cfcamp.org/ http://www.cfcamp.org/

You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/61cd997a-8f53-4795-aaea-b639e15a6879%40googlegroups.com https://groups.google.com/d/msgid/lucee/61cd997a-8f53-4795-aaea-b639e15a6879%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

Yes, that would be great!
Pull requests often get forgotten unfortunately.

Thanks, Paul

Hi Paul

Thanks so much for not only finding the issue, but producing a fix too!

Should I raise a ticket in JIRA mentioning your PR?

Cheers
Julian.Op 24 sep. 2015, om 10:24 heeft Julian Halliwell <@Julian_Halliwell> het volgende geschreven:

On 24 September 2015 at 09:09, Paul Klinkenberg <@Paul_Klinkenberg> wrote:

The underlying problem is here:
Lucee4/lucee-java/lucee-core/src/lucee/runtime/net/smtp/StringDataSource.java at master · lucee/Lucee4 · GitHub
Any html and/or plain text content is converted into a StringDataSource,
which in turn does one WordUtils.wrap on the text / html. Unfortunately, the
org.apache.commons.lang.WordUtils::wrap function handles the incoming string
as one line, regardless of any line break within the string.

A fix could be this:
https://github.com/lucee/Lucee4/commit/ff5b291bf346fd36b23d30e29d6ab5c48c76e631

I have done a pull request on this change now
(Update StringDataSource.java by paulklinkenberg · Pull Request #27 · lucee/Lucee4 · GitHub).

Op 23 sep. 2015, om 16:23 heeft Julian Halliwell <@Julian_Halliwell> het volgende geschreven:

I’ve noticed that mail sent from Lucee (4.5.1.023) has line breaks inserted
every 900 or so characters, despite the fact that the preceding block has
multiple CRLFs and is therefore not a continuous line.


See Lucee at CFCamp Oct 22 & 23 2015 @ Munich Airport, Germany - Get your ticket NOW - http://www.cfcamp.org/

You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAC_5VoqsgGMuPMjhSTDj9ERe%2BBPDMrDdwaJT-YSrK3Lhms6U3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

While I realize this is an old post, I’ve submitted some pull requests to address this in:

https://luceeserver.atlassian.net/browse/LDEV-4039

Instead of sending HTML messages parts using 7bit content transfer encoding, the parts will be sent as quoted-printable which matches the behavior of ACF. The quoted-printable encode automatically wraps each line to 76 characters, but it encodes the line wrapping so that decoded text gets restored without line/word breaks where there are none in the source string.

4 Likes