Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yet another encoding problem #429

Closed
MMaus opened this issue Feb 18, 2022 · 6 comments
Closed

Yet another encoding problem #429

MMaus opened this issue Feb 18, 2022 · 6 comments
Labels
Milestone

Comments

@MMaus
Copy link

MMaus commented Feb 18, 2022

When I run a GreenMail server (as Spring bean) in an application and send an utf-8 coded email with umlauts via Thunderbird, and then fetch that email again via Thunderbird, I might have the wrong encoding.
Whether or not this occurs depends on the encoding which is used for the JVM, i.e. running with -Dfile.encoding=iso-8859-1 works, but -Dfile.encoding=utf-8 does not work (contrary to what you would expect - I know).
I think I spotted the issue in the code - in GreenMailUtil#getWholeMessage treats every String as ISO-8859-1 encoded, and since it transforms byte[] into String (which is UTF-16 in Java), that's actually a conversion of data.

I'm working on a PR to fix this, if that's okay.

Below is the received Mail after my test scenario; the actual message body should be "Täst"

From - Fri Feb 18 10:28:22 2022
X-Account-Key: account4
X-UIDL: 1
X-Mozilla-Status: 0003
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:
Return-Path: foo@test.server
Received: from 127.0.0.1 (HELO [127.0.0.1]); Fri Feb 18 10:28:21 CET 2022
Message-ID: bf6c9320-9c2b-2063-de0a-bfde973b481e@test.server
Date: Fri, 18 Feb 2022 10:28:21 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
To: foo@test.server
From: "[Localhost] Moritz Test" foo@test.server
Subject: =?UTF-8?B?U3ViasOka3Qy?=
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Täst

@marcelmay
Copy link
Member

Thx, @MMaus and looking forward to your PR!

@marcelmay marcelmay added the bug label Feb 18, 2022
@MMaus
Copy link
Author

MMaus commented Feb 18, 2022

If the PR is okay, I can of course provide the corresponding one for master.

@MMaus
Copy link
Author

MMaus commented Feb 19, 2022

I need to re-work this PR

@MMaus
Copy link
Author

MMaus commented Feb 19, 2022

PR is open now - I hope the 1.6.x branch is okay, of course I can provide it for master as well

@marcelmay
Copy link
Member

PR looks good and please make PR against master.

Thanks alot!

@MMaus
Copy link
Author

MMaus commented Feb 20, 2022

I have now created an adapted version of this PR against master (just the imports in the test moved from javax.mail to jakarta.mail).

@marcelmay marcelmay added this to the 2.0.0-alpha-3 milestone Feb 21, 2022
marcelmay pushed a commit that referenced this issue Feb 21, 2022
 #444)

In GreenMail, Strings are usually encoded with ISO-8859-1. This was
missing in the Pop3Connection, so Pop3 messages had encoding problems.
This commit also contains a test which demonstrates the problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants