Uploaded image for project: 'Railo'
  1. Railo
  2. RAILO-3327

CFMAIL incorrectly *hardcodes* Content-Transfer-Encoding as 7bit for content in text/html CFMAILPART tags (all versions of Railo)

    Details

    • Steps to Reproduce:
      Hide

      Run the following code on any flavor of Railo, and on any version of Adobe CF version 9 or greater.

      Where indicated include credentials for a valid SMTP server.

      Send the email to yourself from Railo and Adobe.

      Adobe will send out the email correctly. Railo will send it as an attachment.

      You will see that Railo incorrectly applies the Content-Transfer-Encoding to the parent multipart/alternative container, while the child HTML mailpart is encoded in 7bit.

      --------------
      <cfsavecontent variable="page"><!DOCTYPE html PUBLIC "//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><style type="text/css"><!-body

      { margin: 0 !important; padding: 0 !important; width: 100% !important; -webkit-text-size-adjust: 100% !important; -ms-text-size-adjust: 100% !important; -webkit-font-smoothing: antialiased !important;}

      img

      {border: 0 !important;outline: none !important;}

      table

      {border-collapse: collapse;mso-table-lspace: 0px;mso-table-rspace: 0px;}

      td

      {border-collapse: collapse;mso-line-height-rule: exactly;}

      a

      { width: 100% !important;}

      span

      {mso-line-height-rule: exactly;}

      .ExternalClass *

      {line-height: 100%;}

      .white a

      color: Color value is invalid

      .black a

      color: Color value is invalid

      .grey a

      { color: ##;text-decoration: none;}

      .majento a

      { color: ##BD9A5F;text-decoration: none;}

      .applewhiltelink a

      color: Color value is invalid

      @media only screen and (min-width:481px) and (max-width:600px) {table[class=wrapper]

      { width: 100% !important;}

      table[class=main_table]

      { width: 480px !important;}

      td[class=hide]

      { display: none !important;}

      table[class=hide]

      { display: none !important;}

      span[class=hide]

      { display: none !important;}

      br[class=hide]

      { display: none !important;}

      img[class=full_img]

      { width: 100% !important; height: auto !important;}

      td[class=pad_side]

      { padding-right: 10px !important; padding-left: 10px !important;}

      td[class=fix_width]

      { width: 10px !important;}

      td[class=pad_top]

      { padding-top: 20px !important;}

      td[class=pad_bottom]

      { padding-bottom: 20px !important;}

      td[class=text]

      { text-align: center !important;}

      img[class=mob]

      { width: 63px !important; height: 63px !important;}

      td[class=fix_height]

      { height: 20px !important;}

      --></style></head><body marginwidth="0" marginheight="0" offset="0" leftmargin="0" topmargin="0" bgcolor="##6c6c6c">This is the body of an email.</body></html></cfsavecontent>

      <cfset mailAttributes =

      { server="", username="", password="", from="", to="", subject="HTML Email Test" }

      />

      <cfmail port="587" useTLS="true" attributeCollection="#mailAttributes#" type="text/html" charset="us-ascii" >
      <cfmailparam name="Content-Transfer-Encoding" value="quoted-printable">
      <cfmailparam name="X-Intuvo" value="123-0">
      <cfmailpart type="plain" wraptext="72">This is the test of the email sending out plain text and html</cfmailpart>
      <cfmailpart type="html">#page#</cfmailpart>

      </cfmail>

      Show
      Run the following code on any flavor of Railo, and on any version of Adobe CF version 9 or greater. Where indicated include credentials for a valid SMTP server. Send the email to yourself from Railo and Adobe. Adobe will send out the email correctly. Railo will send it as an attachment. You will see that Railo incorrectly applies the Content-Transfer-Encoding to the parent multipart/alternative container, while the child HTML mailpart is encoded in 7bit. -------------- <cfsavecontent variable="page"><!DOCTYPE html PUBLIC " //W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><style type="text/css"><! -body { margin: 0 !important; padding: 0 !important; width: 100% !important; -webkit-text-size-adjust: 100% !important; -ms-text-size-adjust: 100% !important; -webkit-font-smoothing: antialiased !important;} img {border: 0 !important;outline: none !important;} table {border-collapse: collapse;mso-table-lspace: 0px;mso-table-rspace: 0px;} td {border-collapse: collapse;mso-line-height-rule: exactly;} a { width: 100% !important;} span {mso-line-height-rule: exactly;} .ExternalClass * {line-height: 100%;} .white a color: Color value is invalid .black a color: Color value is invalid .grey a { color: ##;text-decoration: none;} .majento a { color: ##BD9A5F;text-decoration: none;} .applewhiltelink a color: Color value is invalid @media only screen and (min-width:481px) and (max-width:600px) {table [class=wrapper] { width: 100% !important;} table [class=main_table] { width: 480px !important;} td [class=hide] { display: none !important;} table [class=hide] { display: none !important;} span [class=hide] { display: none !important;} br [class=hide] { display: none !important;} img [class=full_img] { width: 100% !important; height: auto !important;} td [class=pad_side] { padding-right: 10px !important; padding-left: 10px !important;} td [class=fix_width] { width: 10px !important;} td [class=pad_top] { padding-top: 20px !important;} td [class=pad_bottom] { padding-bottom: 20px !important;} td [class=text] { text-align: center !important;} img [class=mob] { width: 63px !important; height: 63px !important;} td [class=fix_height] { height: 20px !important;} --></style></head><body marginwidth="0" marginheight="0" offset="0" leftmargin="0" topmargin="0" bgcolor="##6c6c6c">This is the body of an email.</body></html></cfsavecontent> <cfset mailAttributes = { server="", username="", password="", from="", to="", subject="HTML Email Test" } /> <cfmail port="587" useTLS="true" attributeCollection="#mailAttributes#" type="text/html" charset="us-ascii" > <cfmailparam name="Content-Transfer-Encoding" value="quoted-printable"> <cfmailparam name="X-Intuvo" value="123-0"> <cfmailpart type="plain" wraptext="72">This is the test of the email sending out plain text and html</cfmailpart> <cfmailpart type="html">#page#</cfmailpart> </cfmail>

      Description

      When an CFMAILPART of type text/html is used, the Content-Transfer-Encoding is incorrectly hardcoded as 7bit for that mailpart.

      Another title for this issue could be "Specifying CFMAILPARAM of Content-Transfer-Encoding = 'quoted-printable' incorrectly gets applied to the parent multipart/alternative container when multiple mail parts are used."

      TL;DR - This makes it impossible to send emails correctly with both text and html mail parts, while at the same time trying to apply a mail param of content-transfer-encoding = quoted-printable to the HTML mail part.

      The result is the quoted-printable transfer encoding applies to the parent container, and both mail parts get sent as an email attachment.
      ------

      REAL WORLD USE CASE
      Many times when sending emails, you have the need to include both html and plain mail parts. This allows users who only view plain text email to view a text based version of your email, and users who prefer/allow HTML emails to view the HTML version of the same email, without needing to sending multiple emails. In order to do this correctly, and ensure correct formatting across numerous email clients, it is common practice to encode the HTML mail part with a Content-Transfer-Encoding of BASE64 or QUOTED-PRINTABLE so that the HTML content is correctly transferred with no undesirable line breaks in unwanted locations.

      ROOT CAUSE
      Line 825 in railo / railo-java / railo-core / src / railo / runtime / net / smtp / SMTPClient.java hard codes this to be 7bit. This makes it impossible to transfer encode the HTML portion of the email with anything other than 7bit. When including the following CFMAILPARAM tag ...

      <cfmailparam name="Content-Transfer-Encoding" value="quoted-printable">

      ... the message will be sent with the "parent" mail container having a MIME type of multipart/alternative (correct) with quoted-printable content transfer encoding (incorrect). Content-transfer-encodings should not be applied to multipart containers, but instead should be applied to child mail parts, specifically those that are not of type text or plain (in otherwords, mail parts of type html).

      By applying the quoted-printable transfer encoding to the multipart container, all child parts (text and html) are included in the email as an attachment.

      FIX
      1) When a CFMAILPARAM tag specifies a value for the Content-Transfer-Encoding header AND multiple CFMAILPART tags are included, the Content-Transfer-Encoding header should be applied to child mailparts of type HTML, not the parent multipart/alertnative container. Only if no Content-Transfer-Encoding header is present should an HTML mailpart default to 7bit Content-Transfer-Encoding. One could even argue that HTML mail parts should always default to Content-Transfer-Encoding="quoted-printable" requiring manual intervention if you specifically want an HTML mailpart encoded with 7bit.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                micstriit Michael Offner
                Reporter:
                funkeman Tal Funke-Bilu
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: