alash3al / go-smtpsrv

a tiny package that implements SMTP server for Go projects
MIT License
106 stars 28 forks source link

Charset issue with Windows-1252 (and other ones ?) #13

Closed stouch closed 2 years ago

stouch commented 2 years ago

As I explained here : https://github.com/alash3al/smtp2http/issues/14

There is an issue with ioutil.ReadAll reading bytes of some mail contents in french mails with accents.

It should be better to detect charset in Content-Type and correctly decode with charmap for example.

I m not used in Go programming. I don't think I'm gonna be able to help you fixing this.

alash3al commented 2 years ago

Thanks, @stouch, and sorry for my reply, if you want to merge your PR, I left a comment there to be able to merge

stouch commented 2 years ago

@alash3al Once the PR will be done (https://github.com/alash3al/go-smtpsrv/pull/15), I'll create the PR on smtp2http project,

that seems okay for you ?

alash3al commented 2 years ago

I merged it, thanks @stouch

stouch commented 2 years ago

I had the issue when I sent a mail from a french outlook.com mailbox (it uses this charset or ISO-8859-1). The decoding of accents was failing.

alash3al commented 2 years ago

@stouch I mean why you may use smtp2http itself

stouch commented 2 years ago

go-smtpsrv was not reading (at all) the latin-accents chars (they were parsed as blank char on the decoding) when they came from ISO-8859-1 and Windows-1252 charset.

Here is a payload example that you smtp server was not able to process (the é accents for example, were corrupted) :


From: Debug test <test@hotmail.com>
To: "87b4798e-c02e-4697-a419-ba1e85d04bd3@inbound.test.io"
    <87b4798e-c02e-4697-a419-ba1e85d04bd3@inbound.test.io>
Subject: RE: Debug.
Thread-Topic: Test
Thread-Index: AQHYi6GpnljsNgoOzkewLUuT6hhFMK1mLFDr
Date: Wed, 29 Jun 2022 10:20:04 +0000
Message-ID:
    <test@AM7PR02MB6241.eurprd02.prod.outlook.com>
References: <test@smtp-relay.sendinblue.com>
In-Reply-To: <test@smtp-relay.sendinblue.com>
Content-Language: fr-FR
X-MS-Has-Attach:
X-MS-Exchange-Organization-SCL: -1
X-MS-TNEF-Correlator:
X-MS-Exchange-Organization-RecordReviewCfmType: 0
msip_labels:
Content-Type: multipart/alternative;
    boundary="_000_AM7PR02MB62415B0B390AA7DC486262B1BDBB9AM7PR02MB6241eurp_"
MIME-Version: 1.0

--_000_AM7PR02MB62415B0B390AA7DC486262B1BDBB9AM7PR02MB6241eurp_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Vous pouvez r=E9pondre directement =E0 cet email

--_000_AM7PR02MB62415B0B390AA7DC486262B1BDBB9AM7PR02MB6241eurp_
Content-Type: text/html; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
252">
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div style=3D"font-family: Calibri, Arial, Helvetica, sans-serif; font-size=
: 12pt; color: rgb(0, 0, 0);">

Vous avez diffus=E9
</div>
</body>
</html>

--_000_AM7PR02MB62415B0B390AA7DC486262B1BDBB9AM7PR02MB6241eurp_--
alash3al commented 2 years ago

@stouch

I think you may misunderstand me or I didn't clarify my question well, let's ask again in another word:

I didn't mean why you wanted a fix, but why you wanted software like smtp2http?

Examples:

I mean, your use case itself, not why we did the fix

stouch commented 2 years ago

I use smtp2http because : I send emails to my users, and I allow my users to be able to ReplyTo these emails to my fake smtp (hosted under my specific domain) to then route these emails (with there content... possibly written with french charset) to API http endpoints. That's why I use your awesome lib 👌

Basically, I just want to catch emails from my users with my API 😂

This works for us since months, but we were juste encountering this charset issue.

alash3al commented 2 years ago

Great, thanks for your response and support