Hendrik Jan
Hendrik Jan

Reputation: 4908

Parse raw SMTP email data to get the HTML part (including links)

I am building a Javascript email client for testing purposes.

This client uses smtp-server to recieve emails. This works fine.
However, the recieved content looks like this:

Content-Type: multipart/alternative;
 boundary="--_NmP-8304c67023835a47-Part_1"
From: "Radar Reflector >" <[email protected]>
To: [email protected]
Subject: My Subject
Message-ID: <[email protected]>
Date: Fri, 02 Jul 2021 15:16:14 +0000
MIME-Version: 1.0

----_NmP-8304c67023835a47-Part_1
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Some text here.
----_NmP-8304c67023835a47-Part_1
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Dear you,<br />
Go to this link: <a href=3D"http://mysite.=
vagrant/api/v1/invites/route/invite/JDJhJDEwJGJyc3RQZk5KbEs2T2wveTQ2MmxP=
NWVITUdkVWhqS3ZpdzlKd3ZWU0RlVVFVOTRwbkdXYT/1">Invite Link</a><br />
<br />
Kind regards,<br />
<br />
- Somebody<br />
----_NmP-8304c67023835a47-Part_1--

As you can see, the link address starts with 3D and the dot (.) has been replaced with dot-equal (.=).
When I use another mail client (mailcatcher), I can view the HTML content and it shows the correct address (http://mysite.vagrant/api/v1/invites/route/aanmelden/JDJhJDEwJGJyc3RQZk5KbEs2T2wveTQ2MmxPNWVITUdkVWhqS3ZpdzlKd3ZWU0RlVVFVOTRwbkdXYT/1).

What kind of encoding is used?
How can I translate the HTML-part so that is contains the correct link?

Upvotes: 0

Views: 400

Answers (0)

Related Questions