Uploaded image for project: 'OpenDJ'
  1. OpenDJ
  2. OPENDJ-6222

SMTP messages are sometimes not encoded with the correct charset

    Details

    • Story Points:
      1
    • Support Ticket IDs:

      Description

      The customer is using SMTP notifications, and the message body contains non-ASCII text (e.g. "A test message with a £").

      The message body template was checked, and it was a UTF-8 string containing the correct bytes. (i.e. ending in 0xC2 0xA3)

      The mail received looks like this (in Mail.app's view source):

      [...]
      Subject: Test email
      MIME-Version: 1.0
      Content-Type: text/plain; charset=UTF-8
      Content-Transfer-Encoding: quoted-printable
      
      A test message with a =A3
      

      The message should have ended:

      A test message with a =C2=A3
      

      Note the test results seem to vary somewhat depending on what JVM version is used. Java 9 seemed to be correct, but Java 8 seemed to always be wrong.

      We use MimeMessage.setContent("string", "text/plain") to construct the message body, which does not give us any clear way to control this behaviour.

      Calling MimeMessage.setText("string", null, "plain") looks better, as the null charset argument will cause it to default to the JVM's file.encoding value, which can then be overridden using the mail.mime.charset system property.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cjr Chris Ridd
                Reporter:
                cjr Chris Ridd
                QA Assignee:
                Ondrej Fuchsik
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: