[GH-ISSUE #348] Email decoding issue #232

Closed
opened 2026-03-15 13:21:20 +03:00 by kerem · 6 comments
Owner

Originally created by @D3strukt0r on GitHub (Aug 15, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/348

Hello, we have been trying to figure out for hours now if an email we are sending from our backend is sending the email faulty or if it's mailpit display that's broken, and after rigorous testing we figured something is off with mailpit

Here are a working case (any length shorter or equal to this will work)

example-works.eml.txt

image

And an example where anything longer or equal to this length (not sure if this is actually true) will break

example-broken.eml.txt

image

when being sent to any other mailcatcher software or opening in MS Outlook, it is displayed correctly

image

I hope this can help you identify the issue :)

PS: I tested with Mailpit v1.20.1

Originally created by @D3strukt0r on GitHub (Aug 15, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/348 Hello, we have been trying to figure out for hours now if an email we are sending from our backend is sending the email faulty or if it's mailpit display that's broken, and after rigorous testing we figured something is off with mailpit Here are a working case (any length shorter or equal to this will work) [example-works.eml.txt](https://github.com/user-attachments/files/16622607/example-works.eml.txt) ![image](https://github.com/user-attachments/assets/35bd926a-855e-4ea9-bfea-0ab3667b474c) And an example where anything longer or equal to this length (not sure if this is actually true) will break [example-broken.eml.txt](https://github.com/user-attachments/files/16622612/example-broken.eml.txt) ![image](https://github.com/user-attachments/assets/d2694495-13ec-42c1-a095-bf60cf208313) when being sent to any other mailcatcher software or opening in MS Outlook, it is displayed correctly ![image](https://github.com/user-attachments/assets/55af297d-6c4f-41ee-8178-76437aef052d) I hope this can help you identify the issue :) PS: I tested with Mailpit v1.20.1
kerem closed this issue 2026-03-15 13:21:25 +03:00
Author
Owner

@axllent commented on GitHub (Aug 15, 2024):

@D3strukt0r I can confirm the decoding issue using your sample messages, and I can also confirm that this is originating "upstream" in the jhillyerd/enmime module (which Mailpit uses to decode messages). I was able to replicate it with a simple test to rule out that it is related in any way to Mailpit (see below).

What I can't confirm is whether it has anything to do with your message encoding / structure (I cannot see any obvious issue). It is very strange how just a slight change causes the issue, so it appears to be a possible issue with jhillyerd/enmime.

main.go

package main

import (
	"bufio"
	"fmt"
	"os"

	"github.com/jhillyerd/enmime"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Printf("usage: %s <message>\n", os.Args[0])
		os.Exit(1)
	}

	file, err := os.Open(path.Clean(os.Args[1]))
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	defer file.Close()

	r := bufio.NewReader(file)

	env, err := enmime.ReadEnvelope(r)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	fmt.Println("## TEXT ##")
	fmt.Println(env.Text)
	fmt.Println("## HTML ##")
	fmt.Println(env.HTML)
}

Working example:

go run . example-works.eml.txt 
## TEXT ##
Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben Sie den folge

Nachricht:
öoöo

## HTML ##
    Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben <br />
    <br />Nachricht:<br />
öoöo<br />

Broken example:

go run . example-broken.eml.txt 
## TEXT ##
Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben Sie den folgen

Nachricht:
öoöo

## HTML ##
    Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben S<br />
    <br />Nachricht:<br />
öoöo<br />

My suggestion would be for you to report the issue to jhillyerd/enmime and hopefully someone there can either confirm (and potentially fix) the issue, or explain why your message is causing this. It may be useful to reference this issue to save them time.

<!-- gh-comment-id:2290953673 --> @axllent commented on GitHub (Aug 15, 2024): @D3strukt0r I can confirm the decoding issue using your sample messages, and I can also confirm that this is originating "upstream" in the [jhillyerd/enmime](https://github.com/jhillyerd/enmime) module (which Mailpit uses to decode messages). I was able to replicate it with a simple test to rule out that it is related in any way to Mailpit (see below). What I can't confirm is whether it has anything to do with your message encoding / structure (I cannot see any obvious issue). It is very strange how just a slight change causes the issue, so it appears to be a possible issue with `jhillyerd/enmime`. ### main.go ```go package main import ( "bufio" "fmt" "os" "github.com/jhillyerd/enmime" ) func main() { if len(os.Args) != 2 { fmt.Printf("usage: %s <message>\n", os.Args[0]) os.Exit(1) } file, err := os.Open(path.Clean(os.Args[1])) if err != nil { fmt.Println(err.Error()) os.Exit(1) } defer file.Close() r := bufio.NewReader(file) env, err := enmime.ReadEnvelope(r) if err != nil { fmt.Println(err.Error()) os.Exit(1) } fmt.Println("## TEXT ##") fmt.Println(env.Text) fmt.Println("## HTML ##") fmt.Println(env.HTML) } ``` ### Working example: ```shell go run . example-works.eml.txt ## TEXT ## Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben Sie den folge Nachricht: öoöo ## HTML ## Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben <br /> <br />Nachricht:<br /> öoöo<br /> ``` ### Broken example: ```shell go run . example-broken.eml.txt ## TEXT ## Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben Sie den folgen Nachricht: öoöo ## HTML ## Loggen Sie sich ein, um die Einladung zu akzeptieren oder geben S<br /> <br />Nachricht:<br /> öoöo<br /> ``` My suggestion would be for you to report the issue to [jhillyerd/enmime](https://github.com/jhillyerd/enmime) and hopefully someone there can either confirm (and potentially fix) the issue, or explain why your message is causing this. It may be useful to reference this issue to save them time.
Author
Owner

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

I can confirm that I get the correct decoding using the default Go library, so I am almost 100% certain it's an upstream (enmime) issue. I will continue to investigate and see if I can find a workaround as I'm not entirely sure a fix will come any time soon.

<!-- gh-comment-id:2301171401 --> @axllent commented on GitHub (Aug 21, 2024): I can confirm that I get the correct decoding using the default Go library, so I am almost 100% certain it's an upstream (enmime) issue. I will continue to investigate and see if I can find a workaround as I'm not entirely sure a fix will come any time soon.
Author
Owner

@axllent commented on GitHub (Aug 27, 2024):

I've found the reason why this happens (commented on in the issue you reported) - will wait for a response to try understand why before I look at a solution (assuming it's not a bug).

<!-- gh-comment-id:2311630886 --> @axllent commented on GitHub (Aug 27, 2024): I've found the reason why this happens (commented on in the issue you reported) - will wait for a response to try understand why before I look at a solution (assuming it's not a bug).
Author
Owner

@axllent commented on GitHub (Sep 1, 2024):

@D3strukt0r I have just released v1.20.3 which should provide a solution for your issue. Please confirm it is working correctly for you now? Thanks.

<!-- gh-comment-id:2323222722 --> @axllent commented on GitHub (Sep 1, 2024): @D3strukt0r I have just released [v1.20.3](https://github.com/axllent/mailpit/releases/tag/v1.20.3) which should provide a solution for your issue. Please confirm it is working correctly for you now? Thanks.
Author
Owner

@D3strukt0r commented on GitHub (Sep 2, 2024):

@axllent yes seems to be working fine for me now :)

image

thank you a lot <3

<!-- gh-comment-id:2323860771 --> @D3strukt0r commented on GitHub (Sep 2, 2024): @axllent yes seems to be working fine for me now :) ![image](https://github.com/user-attachments/assets/10012060-2411-41d7-9e0a-15d5b75f8779) thank you a lot <3
Author
Owner

@axllent commented on GitHub (Sep 2, 2024):

That's fantastic, thank you for the feedback.

<!-- gh-comment-id:2323876216 --> @axllent commented on GitHub (Sep 2, 2024): That's fantastic, thank you for the feedback.
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#232
No description provided.