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

text/plain alternative part disappears when adding inline Image #67

Open
knathan1987 opened this issue Mar 6, 2024 · 2 comments · May be fixed by #70
Open

text/plain alternative part disappears when adding inline Image #67

knathan1987 opened this issue Mar 6, 2024 · 2 comments · May be fixed by #70

Comments

@knathan1987
Copy link

text/plain alternative part disappears when adding inline Image

const x = createMimeMessage();
x.setSender({name: "Test", addr: "[email protected]"});
x.setRecipient("[email protected]");
x.setSubject("This is a test");

x.addMessage({
	contentType: 'text/html',
	data: "<h1>Lorem ipsum dolor sit amet...</h1>"
});

x.addMessage({
	contentType: 'text/plain',
	data: "Lorem ipsum dolor sit amet..."
});

x.addAttachment({
	inline: true,
	filename: "test.png",
	contentType: "image/png",
	data: "dGVzdA==",
	headers: { "Content-ID": "test" }
});

x.addAttachment({
	filename: "test.pdf",
	contentType: "application/pdf",
	data: "dGVzdA=="
});

console.log(x.asRaw());

Output:

Date: Wed, 06 Mar 2024 08:25:38 +0000
From: =?utf-8?B?VGVzdA==?= <[email protected]>
To: <[email protected]>
Message-ID: <[email protected]>
Subject: =?utf-8?B?VGhpcyBpcyBhIHRlc3Q=?=
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=lu9hrte8tx

--lu9hrte8tx
Content-Type: multipart/related; boundary=11ntqiz482y

--11ntqiz482y
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<h1>Lorem ipsum dolor sit amet...</h1>

--11ntqiz482y
Content-ID: <test>
Content-Type: image/png; name="test.png"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="test.png"

dGVzdA==
--11ntqiz482y--
--lu9hrte8tx
Content-Type: application/pdf; name="test.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.pdf"

dGVzdA==
--lu9hrte8tx--

Output without "inline: true":

Date: Wed, 06 Mar 2024 08:27:31 +0000
From: =?utf-8?B?VGVzdA==?= <[email protected]>
To: <[email protected]>
Message-ID: <[email protected]>
Subject: =?utf-8?B?VGhpcyBpcyBhIHRlc3Q=?=
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=5fll5crxif3

--5fll5crxif3
Content-Type: multipart/alternative; boundary=qqzy1z2de9f

--qqzy1z2de9f
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Lorem ipsum dolor sit amet...

--qqzy1z2de9f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<h1>Lorem ipsum dolor sit amet...</h1>

--qqzy1z2de9f--
--5fll5crxif3
Content-ID: <test>
Content-Type: image/png; name="test.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.png"

dGVzdA==

--5fll5crxif3
Content-Type: application/pdf; name="test.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.pdf"

dGVzdA==
--5fll5crxif3--
@CanRau
Copy link

CanRau commented May 19, 2024

Just stumbled upon this as well, also so far the inline image isn't working, data base64 encoded data won't show up in the emails source 🤔

@CanRau CanRau linked a pull request May 19, 2024 that will close this issue
@CanRau
Copy link

CanRau commented May 19, 2024

Created a PR #70 which should fix it 🤞🏼

Till then I personally vendored the src into my project so I can move forward 🤓

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

Successfully merging a pull request may close this issue.

2 participants