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

Problems Parsing Emails with Attached Images Due to Missing Content-Type Header from Microsoft Exchange #370

Open
frederikchrlarsen opened this issue Jun 7, 2024 · 0 comments

Comments

@frederikchrlarsen
Copy link

I am having some problems with parsing emails when there is an image attached. It seems like the email sender (Microsoft Exchange) does not include Content-Type: text/plain; charset="iso-8859-1" (see "successful" email), but instead includes it embedded in the html of the email itself like: <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset= =3Diso-8859-1"> (see "failing" email)

If I manually set the charset in mail-parser.js to iso-8859-1 the "failing" email is decoded correctly and the expected output is received

image

Failing email

I have removed sensitive information

Delivered-To: [email protected]
Content-Type: multipart/related;
        boundary="_f296c068-7ef1-4c7a-b03e-49534e067c56_"
From: =?iso-8859-1?Q?Asd_S=F8nasd_S=F8asd?= <[email protected]>
To: "[email protected]" <Test>
Subject: Test
Thread-Topic: Test
Date: Thu, 6 Jun 2024 10:46:09 +0000
Accept-Language: da-DK, en-US
Content-Language: da-DK
MIME-Version: 1.0

--_f296c068-7ef1-4c7a-b03e-49534e067c56_
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Diso-8859-1">
<meta name=3D"Generator" content=3D"Microsoft Exchange Server">
<!-- converted from text -->
<style>.EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800=
000 2px solid; }</style></head>
<body>
<font size=3D"2"><div class=3D"PlainText">Kundenr*:;12345678<br>
Kundenavn*:;Teeest - Test<br>
Adresse*:;Testvej 1234<br>
Postnummer*:;1234<br>
By*:;Testby<br>
Mail*:;[email protected]<br>
Telefon*:;&#43;45 12345678<br>
;<br>
Husst=F8rrelse:;<br>
Nuv=E6rende opvarmning:;<br>
Nuv=E6rende forbrug:;<br>
;<br>
Qkunde;Teeest - Test<br>
Qskabelon;Testvejledning<br>
</div></font></body>
</html>

--_f296c068-7ef1-4c7a-b03e-49534e067c56_
Content-Description: image.png
Content-Type: image/png;
        name="image.png"
Content-Disposition: inline;
        filename="image.png"
Content-Transfer-Encoding: base64
Content-ID: <image.png>


PartOfImageRemovedIxi4+WijaUHzdkI+AiXsryMNP8S2qDCFxNJJFwKxwIYhaQqRyyLzVRT8Jo
l/HzdUku4QQhZtEbvF2a9jT7dOS8iq/gFFknzFVdd2RJLDJkX6l/utJ4SUkucYHcOAFmExd/sCxm
kYljW7NkoBpFzpy2hUvTmmtzRcL1KEnlWatcIJvpxdrNRThCFv4aTaKlcaMYyyDdWtrJQEYBVcdn
HsW1QJStcpgYWi2COIV99O4eg/CrZFM39rC3buoA72HBoH6d1JCksYCXTs3aNDwfNbQHtwn8m60I
veVLBWrGjAjDEEkmSc/CBygUcYkehEL8iE+vMcxYzxaAM3NFkAXRQ3I/ZDJzAa9iOMLl+pDnS6G4
PU4ojArDkCzDKougDn9pi4kn0TFTptCQNHzadzIVbhwSCJgmLGwKR0LBy0+uU0uObG+2IgxDMvXI
m59c9UFbpLZr8MiGABwk8w9W4BmSELN53WVJzes+Neig48+q9uSzb9J/ufKFtmbIQ7KDEYKv+2lo
UaVQTRa/dHn1gSezmI0Z8mvhFC+RDkhGc77kJlLnc5vHFPVw6XMPd7jWnssYJDnMscizVxOGo4hw
8I3O99CjkIS8CUlNbkJZDSIXzt9p80J48ZDTgSQXsPMGb1qmnOBT3CCRoHM4NxCKTEBkgPP5LvoX
ZhC+7mWnQXEdtalhmBSebU+z4TkThnHITahlIbEuuvPDr8uxsXLB8nmbC/10sZ9ikv8B0H3pMaXq
vGwAAAAASUVORK5CYII=

--_f296c068-7ef1-4c7a-b03e-49534e067c56_--

Successful email (no image attached)

I have removed sensitive information

Delivered-To: [email protected]
From: test <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Test
Thread-Topic: Test
Date: Fri, 7 Jun 2024 09:29:21 +0000
Accept-Language: da-DK, en-US
Content-Language: da-DK
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

Kundenr*:;1234
Kundenavn*:;Test test
Adresse*:;test 7, test
Postnummer*:;123
By*:;test
Mail*:;[email protected]
Telefon*:;12345678
;
Husst=F8rrelse:;
Nuv=E6rende opvarmning:;
Nuv=E6rende forbrug:;
;
Qnavn;test 7, test, 1234 Test - Test
Qkunde;Test Test
Qskabelon;Testvejledning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant