Coding Phase - Week 4 Report

yes sure

The RFC 822 specification defines an electronic message format, and this format is what I will receive from IMAP. It contains everything related to the message: headers (from, to, cc, etc.), text, images, media, and attachments.

This format deals with embedded images or attachments by the cid (content-id). Each image or attachment has a unique cid and this contains everything related to the image or attachment, from type, size, and the type of encoding of that attachment, like Base64.

Each content is separated from the other by a boundary that is specified at the beginning of the message.

example:

------------ An example of the header content: -----------------------

Delivered-To: bishoy.magdy.adeeb@gmail.com
Received: by 2002:a05:7110:70c2:b0:188:87bb:ab55 with SMTP id k5csp2160218geh;
Date: Sun, 3 Jul 2022 17:03:42 +0300 (MSK)
From: Codeforces@codeforces.com
To: bishoy98magdy@gmail.com
Message-ID: <1151498597.262915.1656857022443.JavaMail.Codeforces@codeforces.com>
Subject: Codeforces Round 804 (Div. 2)

------------ An example of the message content: -----------------------

[cid:colors-top]
Hi bishoy,
        Welcome to your new account. Outlook lets you stay conn=
ected, organized, and productive=97at work, at home, and everywhere in betw
een.
[cid:devices.png]
Discover a more productive inbox across all your devices
Managing your busy life shouldn't be difficult. With email and calendar in =
just one service, Outlook makes it easy for you to stay on top of it all =
=97 whether you're catching up on conversations, setting up coffee dates, o=
r organizing a weekend trip.
[cid:colors]

-------------------Boundary-------------------------
Content-Type: multipart/related;
boundary="_013_AM9P193MB16520D9165C9144487C176BC8BBA9AM9P193MB1652EURP_";
	type="multipart/alternative"
	
.
..
...
....
------------- An example of the cid content: -------------

--_013_AM9P193MB16520D9165C9144487C176BC8BBA9AM9P193MB1652EURP_
Content-Type: image/png; name="colors.png"
Content-Description: colors.png
Content-Disposition: inline; filename="colors.png"; size=5306;
	creation-date="Sun, 12 Jun 2022 17:21:36 GMT";
	modification-date="Thu, 30 Jun 2022 12:44:28 GMT"
Content-ID: <colors>
Content-Transfer-Encoding: base64
iVBORw0KGgoAAAANSUhEUgAAAHIAAABrCAYAAACrBNYuAAAAAXNSR0IArs4c6QAAFHRJREFUeAHt
XQtwXNV5PufuXUm2JdtgWxa2JT8SwBgwBoxkYWOLOCaYSUvq1Elp+qCdBhIDSTudNG3aMm4amrQz
JGmaIdRhJnQC06QmnTbphJY4xIDxK8QYY+yMAWNJli2/MJatx2r33tP/v1ef9vf1rrS72l3d3eXM
7P7/+c//ncf/3XPfD63eT6pt4y9s9d682n4zsdqNJ6psFa1OaKc6oky1cSMJSw/22VU1vYOO1Tth

--_013_AM9P193MB16520D9165C9144487C176BC8BBA9AM9P193MB1652EURP_
Content-Type: image/png; name="devices.png"
Content-Description: devices.png
Content-Disposition: inline; filename="devices.png"; size=94183;
	creation-date="Sun, 12 Jun 2022 17:21:36 GMT";
	modification-date="Thu, 30 Jun 2022 12:44:28 GMT"
Content-ID: <devices.png>
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAABwgAAAPUCAMAAACO/p3zAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
bWFnZVJlYWR5ccllPAAAA4ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdp
bj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbn

--_013_AM9P193MB16520D9165C9144487C176BC8BBA9AM9P193MB1652EURP_
.
..
....
-----------------------HTML formate------------------------
--_013_AM9P193MB16520D9165C9144487C176BC8BBA9AM9P193MB1652EURP_
html content
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit


and so on

It also has other large amounts of information about the message, like ARC-Seal, ARC-Message-Signature, and other complex information.

I will pass this format to the parser and I will get an object containing the HTML, Text, array of attachments, from, to,...

2 Likes