DusanKasan / parsemail

Simple email parsing for Golang
MIT License
212 stars 138 forks source link

plain text attachments are parsed as if they are part of TextBody #35

Closed ComaVN closed 3 years ago

ComaVN commented 3 years ago

When sending a plain text file as an attachment to an email, the parser treats it as part of the body, and will just append it to the TextBody, and leave the Attachments slice empty

example mail:

From: John Doe <john.doe@example.com>
Content-Type: multipart/mixed; boundary="Apple-Mail=_D95A65F4-8972-4641-871C-AE6A660FEA26"
Subject: has attachment
Date: Fri, 27 Apr 2012 16:55:53 +0200
Message-Id: <A29676F6-D644-4013-84F0-3F8B9DA4EAEB@on2it.net>
To: jane.doe@example.com
Mime-Version: 1.0 (Apple Message framework v1257)
X-Mailer: Apple Mail (2.1257)

--Apple-Mail=_D95A65F4-8972-4641-871C-AE6A660FEA26
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
    charset=us-ascii

test

--Apple-Mail=_D95A65F4-8972-4641-871C-AE6A660FEA26
Content-Disposition: attachment;
    filename=test.txt
Content-Type: text/plain;
    x-unix-mode=0644;
    name="test.txt"
Content-Transfer-Encoding: quoted-printable

testfile

--Apple-Mail=_D95A65F4-8972-4641-871C-AE6A660FEA26--

Expected result of parsemail.Parse: TextBody is test, Attachments has a single attachment containing the plain-text file

Actual result: TextBody is testtestfile, Attachments is empty

ComaVN commented 3 years ago

Never mind, this seems to be a bug that was introduced in one of the forks I was using

XiaoLiu1020 commented 2 years ago

I have this problem, I cannot get the attachsment? how can I? @ComaVN

agentabstract commented 2 years ago

I'm having this same issue. If I attach an email with a .txt extension it shows up in the TextBody field and not as an attachment. If I change the extension to ".1" and send it, that is read as an attachment. Any ideas?

guiferpa commented 1 year ago

Up

blmayer commented 1 year ago

I am using this fork and it works:

https://github.com/EVANA-AG/parsemail