Email: Message Format

Let's study the exact format of an email message!

Introduction

Email messages have a format the same way that HTTP request and response messages do. Let’s dive right into it.

Header Lines

Email messages start with header lines, much akin to HTTP. The header lines contain important metadata about the email.

  • The header lines consist of keywords followed by a colon, followed by a value.
  • Every header line is separated by a new line with a carriage return (\r).
  • Every header must have the To: and From: header lines.
  • The rest of the headers, including the subject: header line, are optional.

Message Body

The message body of the email follows the header lines after a blank line.

Here is an example of what an email message looks like:

Exercise: View Raw Emails

Open up your favorite email agent. Google search “view headers with name of agent.” For example, I could Google “view headers with Gmail.” Here are some instructions for common clients:

  1. Gmail
  2. Outlook
  3. Yahoo!

Once you have the instructions, study the headers. Can you figure out what each does? For your reference, here is a sample of email headers. Note that they are a bit simplified for your ease.

Delivered-To: user@gmail.com
Date: Thu, 16 May 2019 03:36:28 +0000 (UTC)
From: Fahim from Educative <fahim+newsletter@educative.io>
Mime-Version: 1.0
Reply-to: fahim@educative.io
Subject: Data analysis with R
To: user@gmail.com

Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Mime-Version: 1.0

Hey User,

With the way technology is evolving, more and more data is being produced a=
nd tracked every day. And because of that, the skills to work with that dat=
a, to make sense of it and turn into useful insight, are more in-demand tha=
n ever before.

If recent trends are anything to go by, in the future the ability to work w=
ith large quantities of data won=E2=80=99t be the field of just data scient=
ists - it=E2=80=99s going to become a necessary skill across industries, ki=
nd of like using a word processor.

For years, R has been at the forefront of the data science revolution. It=
=E2=80=99s beloved by data scientists and statisticians for its robust stat=
istical functionality, outstanding graphing ability, and extensibility thro=
ugh packages. The recent data science craze has just breathed new life into=
 it.

Learn R from Scratch https://www.educative.io/collection/6151088528949248/5=
357220915052544?utm_source=3Dsendgrid&utm_medium=3Demail&utm_campaign=3Dlea=
rn-r-from-scratch&utm_content=3D is designed to get you up to speed writing=
 code in R as quickly as possible. You'll start with the very basics and wo=
rk your way up to advanced concepts like exception handling. By the time yo=
u're done, you'll be able to write detailed, useful code in R yourself.

Get started with R, stay on top of the data science craze, and solve real-w=
orld problems with data.

Happy learning!

-- Fahim

CEO & co-founder, educative.io=20

1203 114th Ave SE,=20
Bellevue, WA 98004

Note the headers are from a received email and not the headers when it was sent, which is what we discussed initially. So, the Delivered-To header is derived from the To: header in the originally sent email. The SMTP or the POP server probably make this transformation. More likely the SMTP server.

If you wish to study each of these headers and the format in detail, have a look at RFC5322.

Please attempt the question in the widget below. Our AI will evaluate your answer.

How do you think attachments of binary files, such as zip files, work when email uses a text-based protocol?
1

Why is SMTP not used for transferring emails from the recipient’s mail server to the recipient’s user agent?

A)

SMTP is a push protocol whereas the task of transferring email messages from the recipient’s mail server to the recipient’s personal computer is a pull operation.

B)

SMTP is a pull protocol, whereas the task of transferring email messages from the recipient’s mail server to the recipient’s personal computer is a push operation.

C)

SMTP is a push protocol whereas the task of transferring email messages to the recipient’s mail server from the recipient’s personal computer is a pull operation.

D)

SMTP is a pull protocol whereas the task of transferring email messages to the recipient’s mail server from the recipient’s personal computer is a push operation.

Question 1 of 70 attempted

Now that we have a good idea of email, let’s move on to the directory of the web: DNS.

Get hands-on with 1400+ tech skills courses.