Unwanted line breaks in mail body

175 views
Skip to first unread message

Julian Halliwell

unread,
Sep 23, 2015, 10:23:40 AM9/23/15
to Lucee
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 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:

<cfscript>
crlf=Chr( 13 ) & Chr( 10 );
lineEndingInABreak="one two three" & crlf;
textWithLineBreaks=RepeatString( lineEndingInABreak,140 );
</cfscript>
<!--- 1. Mail with no additional attributes--->
<cfmail from="from@localhost" to="to@localhost" subject="Just line breaks"><cfoutput>#textWithLineBreaks#</cfoutput></cfmail>
<!--- 2. Wrap text at 72--->
<cfmail from="from@localhost" to="to@localhost" subject="Line breaks plus wrap text at 72" wraptext="72"><cfoutput>#textWithLineBreaks#</cfoutput></cfmail>
<!--- 3. Quoted printable--->
<cfmail from="from@localhost" to="to@localhost" subject="Line breaks plus Quoted-Printable"><cfmailparam name="Content-Transfer-Encoding" value="quoted-printable"/><cfoutput>#textWithLineBreaks#</cfoutput></cfmail>

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/


Paul Klinkenberg

unread,
Sep 24, 2015, 4:09:28 AM9/24/15
to lu...@googlegroups.com
Hi Julian,

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.


I have done a pull request on this change now (https://github.com/lucee/Lucee4/pull/27).

Kind regards,

Paul Klinkenberg



--
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+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/61cd997a-8f53-4795-aaea-b639e15a6879%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julian Halliwell

unread,
Sep 24, 2015, 4:24:31 AM9/24/15
to lu...@googlegroups.com
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.

On 24 September 2015 at 09:09, Paul Klinkenberg
<pa...@ongevraagdadvies.nl> wrote:
> The underlying problem is here:
> 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:
> https://github.com/lucee/Lucee4/commit/ff5b291bf346fd36b23d30e29d6ab5c48c76e631
>
> I have done a pull request on this change now
> (https://github.com/lucee/Lucee4/pull/27).
>

Paul Klinkenberg

unread,
Sep 24, 2015, 4:38:29 AM9/24/15
to lu...@googlegroups.com
Yes, that would be great!
Pull requests often get forgotten unfortunately.

Thanks, Paul
--
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+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAC_5VoqsgGMuPMjhSTDj9ERe%2BBPDMrDdwaJT-YSrK3Lhms6U3w%40mail.gmail.com.

Julian Halliwell

unread,
Sep 24, 2015, 5:08:15 AM9/24/15
to lu...@googlegroups.com
OK, done:

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


On 24 September 2015 at 09:38, Paul Klinkenberg
<pa...@ongevraagdadvies.nl> wrote:
> Yes, that would be great!
> Pull requests often get forgotten unfortunately.
>
Reply all
Reply to author
Forward
0 new messages