On the Internet, e-mail is one of the most widely used network services. It’s used to quickly exchange messages and files in both professional and private environments. Its flexibility makes it easy to use on a wide range of devices, including computers, smartphones and tablets. In this article, we’ll take a look at the structure of an email in order to understand the difficulties and problems that can be encountered. How is an e-mail message structured?
To send an e-mail, you need to follow the structure recommended by RFC 2821 (taken from RFC 821): an envelope, a header, a message body and, if necessary, attachments.
The message envelope
The envelope consists of the information that ensures the effective transfer of the e-mail from one mail server to another. It includes the “MAIL FROM” sender address, the “RCPT TO” recipient address and the “DATA” data (containing headers, body and attachments).
Part of the e-mail header is generated automatically by the MUA (Mail User Agent, e-mail client) software, while others are added directly by the mail server or intermediary mail relays (for the “Received” field in particular). Header fields are therefore made up of several header parameters, some of which are essential for e-mail:
– From: the e-mail address of the sender of the message. Ex: email@example.com
– To: recipient’s e-mail address, i.e. the address to which you are sending the message. Ex: firstname.lastname@example.org
– Date: the date on which the mail is sent. If you don’t specify a date, the mail server will add it.
– Received: information on all the mail servers through which the mail passes: sender server, intermediate servers and recipient server. This field contains the names, IP addresses and dates of e-mail processed by all servers.
– Reply-To: alternative address to the From field for receiving a reply.
– Subject: the subject of the message. This subject can be in ASCII or encapsulated in specific MIME (encoding).
– Message-ID: reference that uniquely identifies your message.
The message body
The message consists mainly of the mail header and the message body. The body of the message is the actual message you write to send to the recipient. It will be directly integrated into the email if it is plain text (ASCII). In the case of formatted messages (HTML for example), it will then take the form of MIME encoding integrated into the email.
Attachments, images and formatted messages
The images contained in the message (not downloaded), the formatted version of the message (in HTML, for example) and any attachments are attached to the message using the MIME protocol. This protocol is presented in a specific MIME article. The advantage is that you can use any type of character, whereas messaging works natively on a 7-bit character set only.
Example of an e-mail structure
MAIL FROM : email@example.com
RCPT TO : firstname.lastname@example.org
From: "Expéditeur" <email@example.com>
To: "Destinataire" <firstname.lastname@example.org>
Subject: Structure d’un courrier électronique
Bonjour, ceci est
Note that without the essential header information, it’s impossible to route your message. It would be like sending a document by post without the header containing your recipient’s home address.