Sending picture file in an email

It is easy to attach a picture in an email, from user's perspective, of course. But, what is actually sent over the Internet to the recipient server?

There are 2 types how a picture can be transmitted over an email, as inline picture, or as an attachement. Before they are transfer over, they need to go through some conversion, that is binary-to-text encoding called Base64.

Say, the binaries of the image starts with FF D8 FF, and the translation process can be as below :

Original binaries FF   D8   FF
Regroup the binaries111111111101100011111111
Associate decimal 62613563
From the Base64 index table /9j/

Inline image

To send as an inline, the email message shall have the following attributes.

Content-Type: image/gif; name="file name"
Content-Transfer-Encoding: base64
X-Attachment-Id: image-id
Content-ID: <image-id>
Followed by the image binaries in Base64. The attributes and the image binaries is placed within the content type boundary.

In the email content, to refer to the image, the source of image will be refered as

<img src="cid:image-id">

Attachment image

For image as an attachment (for download), the email message attributes will be different from the inline image.

Content-Type: image/gif; name="file name"
Content-Disposition: attachment; filename="file name"
Content-Transfer-Encoding: base64
X-Attachment-Id: image-id

Similar to inline image, the message is followed by the image binaries in Base64 format, and is enclosed within the content type boundary.

The highlighted are basically the attributes that differentiate the inline image and attachment image.


Popular posts from this blog

Network Manager

CCSP Domain 2 : Cloud Data Security - Part 2

How to enable LAN network to access to web server hosted in Oracle VirtualBox