dmurvihill/courier

Charset problems

Closed this issue · 6 comments

I have a problem with encoding. Am I doing something wrong or there is a problem with Coureir? How can I fix this?

I am sending:

  <html>
    <head>
      <meta charset="UTF-8" />
    </head>
    <body>
      <h1>Diacritics: żółć</h1>
    </body>
  </html>

and getting:

<h1>Diacritics: ?�??</h1>

the email looks like this:

------=_Part_0_1597551722.1405604258142
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
    <head>
      <meta charset=3D"text/html; charset=3DUTF-8"/>
    </head>
    <body>
      <h1>Diacritics: ?=F3??</h1>
    </body>
  </html>
------=_Part_0_1597551722.1405604258142--

I have the same issue, not able to see unicode characters when using Multipart. The language I am testing with is Chinese. The characters are replaced by "???" in the final output

val msg = "<div>陆文泰</div>"
Multipart().html(msg)

yields "<div>???</div>" in my email output

Is there any known solution / workaround ?

I'll have to have a look but my first guess would be the that i's using the default character encoding on your system. You can figure out what this is by logging System.getProperty("file.encoding") you can also make sure this is set to utf-8 but specifying it as

java -Dfile.encoding=utf-8 ...

when you run your app

You can do something like:

      content(
        Multipart().add({
          val part = new MimeBodyPart
          part.setText(body, StandardCharsets.UTF_8.name(), "html")
          part
        }
      ))

Current version also does not allow to set encoding at the Subject level. In our case we have special characters in subject as well.

Subject charset problem has been resolved #29

It should be fixed in 1.0.0-RC1.