FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support having different Content-Transfer-Encoding in multipart messages · Issue #605 · bbottema/simple-java-mail · GitHub

Support having different Content-Transfer-Encoding in multipart messages #605

Description

Hi.
I noticed that when parsing an email from its .eml representation and sending it over to an SMTP server using simple-java-mail the Content-Transfer-Encoding header is changed for some parts of the message.
For example:
This is my .eml file:

From: sender@example.com
To: recipient@example.com
Subject: Example multipart message
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="boundary123"

--boundary123
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hello,
This is the plain text version of the email.

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

<html>
  <body>
    <p>Hello,</p>
    <p>This is the <b>HTML</b> version of the email.</p>
    <p>Notice the non-breaking space:&nbsp; and =C2=A9 symbols.</p>
  </body>
</html>

--boundary123--

After parsing it from a file and sending it to the SMTP like this:

var eml = Files.readString("etc etc");
var email = EmailConverter.emlToEmail(eml);
mailer.sendEmail(email);

What I got on the other side is something like this:

Content-Type: multipart/alternative; 	boundary="----=_Part_0_416639874.1756482293892"
Date: Fri, 29 Aug 2025 12:44:53 -0300 (ART)
From: sender@example.com
MIME-Version: 1.0
Message-ID: <mex07fbe.1hqvcchgqwx16@localhost>
Received: from 192.168.250.164 by mailhog.example (MailHog)
          id tAWW2y0A1KytqNjlzp-_FEnAc7Bp0tL-2zyDcHhq_o0=@mailhog.example; Fri, 29 Aug 2025 15:44:53 +0000
Reply-To: sender@example.com
Subject: Example multipart message
To: recipient@example.com

------=_Part_0_416639874.1756482293892
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hello,
This is the plain text version of the email.

------=_Part_0_416639874.1756482293892
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: 7bit

<html>
  <body>
    <p>Hello,</p>
    <p>This is the <b>HTML</b> version of the email.</p>
    <p>Notice the non-breaking space:&nbsp; and © symbols.</p>
  </body>
</html>

------=_Part_0_416639874.1756482293892--

Please note that in the second part of the message, the Content-Transfer-Encoding was changed fro quoted-printable to 7bit. I think that the converter is just taking the first Content-Transfer-Encoding that it sees and applying it to every part that the message has.

Do you think there's a way that having different transfer encodings for each part can be supported?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL