[GH-ISSUE #318] UTF-8 Email text is not decoded correctly #209

Closed
opened 2026-03-15 13:13:44 +03:00 by kerem · 7 comments
Owner

Originally created by @antonionardella on GitHub (Jun 20, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/318

Hello!

The email text is not decoded correctly on the website:
image
image

If you can tell me where to look, I can try to fix that.

Best,
Antonio

Originally created by @antonionardella on GitHub (Jun 20, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/318 Hello! The email text is not decoded correctly on the website: ![image](https://github.com/axllent/mailpit/assets/7383572/f25f71bb-a437-4f97-a7e9-0c2c7707282f) ![image](https://github.com/axllent/mailpit/assets/7383572/b34dec34-e4f6-43a2-b216-c3095092d46e) If you can tell me where to look, I can try to fix that. Best, Antonio
kerem 2026-03-15 13:13:44 +03:00
  • closed this issue
  • added the
    stale
    label
Author
Owner

@axllent commented on GitHub (Jun 20, 2024):

I've seen this before, and I don't think it's a Mailpit issue at all but rather an email encoding issue (not encoding the subject header correctly and not specifying utf8 encoding for the body). Please could you attach a raw copy of an email (including header and body) which has this problem so I can test? Thanks.

<!-- gh-comment-id:2180298950 --> @axllent commented on GitHub (Jun 20, 2024): I've seen this before, and I don't think it's a Mailpit issue at all but rather an email encoding issue (not encoding the subject header correctly and not specifying utf8 encoding for the body). Please could you attach a raw copy of an email (including header and body) which has this problem so I can test? Thanks.
Author
Owner

@antonionardella commented on GitHub (Jun 20, 2024):

The email itself is then shown correctly and the raw email is here:

Return-Path: <[REDACTED]>
Received: from zammad-web (localhost [127.0.0.1])
        by zammad-web (Mailpit) with SMTP
        for [REDACTED]; Thu, 20 Jun 2024 10:08:48 +0000 (UTC)
Message-ID: <559381.105096207-sendEmail@zammad-web>
From: "[REDACTED]" [REDACTED]
To: "[REDACTED]" [REDACTED]
Subject: RE: Email Testing [Ticket#202406201000188]
Date: Thu, 20 Jun 2024 10:08:48 +0000
X-Mailer: sendEmail-1.56
MIME-Version: 1.0
Content-Type: multipart/related; boundary="----MIME delimiter for sendEmail-108049.040501104"

This is a multi-part message in MIME format. To properly display this message you need a MIME-Version 1.0 compliant Email program.

------MIME delimiter for sendEmail-108049.040501104
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Danke dir, alles gelöst

------MIME delimiter for sendEmail-108049.040501104--

As shown gelöst is written correctly here

<!-- gh-comment-id:2180310587 --> @antonionardella commented on GitHub (Jun 20, 2024): The email itself is then shown correctly and the raw email is here: ``` Return-Path: <[REDACTED]> Received: from zammad-web (localhost [127.0.0.1]) by zammad-web (Mailpit) with SMTP for [REDACTED]; Thu, 20 Jun 2024 10:08:48 +0000 (UTC) Message-ID: <559381.105096207-sendEmail@zammad-web> From: "[REDACTED]" [REDACTED] To: "[REDACTED]" [REDACTED] Subject: RE: Email Testing [Ticket#202406201000188] Date: Thu, 20 Jun 2024 10:08:48 +0000 X-Mailer: sendEmail-1.56 MIME-Version: 1.0 Content-Type: multipart/related; boundary="----MIME delimiter for sendEmail-108049.040501104" This is a multi-part message in MIME format. To properly display this message you need a MIME-Version 1.0 compliant Email program. ------MIME delimiter for sendEmail-108049.040501104 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Danke dir, alles gelöst ------MIME delimiter for sendEmail-108049.040501104-- ``` As shown `gelöst` is written correctly here
Author
Owner

@axllent commented on GitHub (Jun 20, 2024):

I think it's because of the charset="iso-8859-1" encoding specified in the content type. This should be utf-8

The email itself is then shown correctly

Where does it display correctly?

<!-- gh-comment-id:2180320761 --> @axllent commented on GitHub (Jun 20, 2024): I _think_ it's because of the `charset="iso-8859-1"` encoding specified in the content type. This should be utf-8 > The email itself is then shown correctly Where does it display correctly?
Author
Owner

@antonionardella commented on GitHub (Jun 20, 2024):

The word is displayed correctly within the raw email and in the mail client

<!-- gh-comment-id:2180431930 --> @antonionardella commented on GitHub (Jun 20, 2024): The word is displayed correctly within the raw email and in the mail client
Author
Owner

@axllent commented on GitHub (Jun 21, 2024):

Ahh yes, I see what is confusing you. The RAW message is displayed using UTF-8 because that is the default in Mailpit, and the raw message contains everything (headers, message parts etc). The issue here is that the email itself specifies that the encoding for the text part is encoded with (and so also should be decoded with) iso-8859-1 which is not correct. The email client is ignoring the iso-8859-1 (which it shouldn't be, but I can't comment on that).

Just to be clear, Mailpit is displaying the message correctly (doing exactly what it should), the problem here is the message itself.

This fails (what you are getting)....

From: <test@test.com>
To: <test2@test.com>
Subject: Bad encoding
MIME-Version: 1.0
Content-Type: multipart/related; boundary="----MIME delimiter for sendEmail-108049.040501104"

This is a multi-part message in MIME format. To properly display this message you need a MIME-Version 1.0 compliant Email program.

------MIME delimiter for sendEmail-108049.040501104
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Danke dir, alles gelöst

------MIME delimiter for sendEmail-108049.040501104--

This however renders the message correctly:

From: <test@test.com>
To: <test2@test.com>
Subject: Bad encoding
MIME-Version: 1.0
Content-Type: multipart/related; boundary="----MIME delimiter for sendEmail-108049.040501104"

This is a multi-part message in MIME format. To properly display this message you need a MIME-Version 1.0 compliant Email program.

------MIME delimiter for sendEmail-108049.040501104
Content-Type: text/plain;
        charset="UTF-8"
Content-Transfer-Encoding: 7bit

Danke dir, alles gelöst

------MIME delimiter for sendEmail-108049.040501104--

The fix is that sendEmail should be encoding the message part using charset="UTF-8", not charset="iso-8859-1".

<!-- gh-comment-id:2181929296 --> @axllent commented on GitHub (Jun 21, 2024): Ahh yes, I see what is confusing you. The RAW message is displayed using UTF-8 because that is the default in Mailpit, and the raw message contains everything (headers, message parts etc). The issue here is that the email itself specifies that the encoding for the text part is encoded with (and so also should be decoded with) `iso-8859-1` which is **not correct**. The email client is ignoring the `iso-8859-1` (which it shouldn't be, but I can't comment on that). Just to be clear, Mailpit is displaying the message correctly (doing exactly what it should), the problem here is the message itself. This fails (what you are getting).... ``` From: <test@test.com> To: <test2@test.com> Subject: Bad encoding MIME-Version: 1.0 Content-Type: multipart/related; boundary="----MIME delimiter for sendEmail-108049.040501104" This is a multi-part message in MIME format. To properly display this message you need a MIME-Version 1.0 compliant Email program. ------MIME delimiter for sendEmail-108049.040501104 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Danke dir, alles gelöst ------MIME delimiter for sendEmail-108049.040501104-- ``` This however renders the message correctly: ``` From: <test@test.com> To: <test2@test.com> Subject: Bad encoding MIME-Version: 1.0 Content-Type: multipart/related; boundary="----MIME delimiter for sendEmail-108049.040501104" This is a multi-part message in MIME format. To properly display this message you need a MIME-Version 1.0 compliant Email program. ------MIME delimiter for sendEmail-108049.040501104 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Danke dir, alles gelöst ------MIME delimiter for sendEmail-108049.040501104-- ``` The fix is that sendEmail should be encoding the message part using `charset="UTF-8"`, not `charset="iso-8859-1"`.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 29, 2024):

This issue has been marked as stale because it has been open for 7 days with no activity.

<!-- gh-comment-id:2197840664 --> @github-actions[bot] commented on GitHub (Jun 29, 2024): This issue has been marked as stale because it has been open for 7 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (Jul 2, 2024):

This issue was closed because there has been no activity since being marked as stale.

<!-- gh-comment-id:2201651850 --> @github-actions[bot] commented on GitHub (Jul 2, 2024): This issue was closed because there has been no activity since being marked as stale.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#209
No description provided.