Broad Network


Email Structure and ECMAScript

Sending Email with ECMAScript – Part 1

ECMAScript 6

Foreword: In this part of the series I talk about email structure basics.

By: Chrysanthus Date Published: 15 Jul 2016

Introduction

This is part 1 of my series, Sending Email with ECMAScript. In this part of the series I talk about email structure basics. I assume that you have been sending emails and you are already familiar with some of the basic terms like email address. For this series, I will talk mainly about sending email; I will not talk about replying or forwarding email.

The aim of the series is to teach webmasters how to send emails from web page forms. There are many email agents or software today that will send, receive, reply and forward emails for you. As a webmaster, your primary aim with emails is how to send emails from HTML (web) forms.

Pre-Knowledge
At the bottom of this page, you have links to the different series you should have read before coming here. This series is a continuation.

Client and Server
When you sit in your home or office and send an email, the computer you use is the client computer. The email will pass through the Internet wire (and space) and arrive at another computer that keeps and maintains emails. This second computer is the server computer. The program in the server computer that actually does the keeping and maintenance of emails is called the email server. So both a computer and a program can be called a server. When the person to whom the email was sent thinks he has an email, he would logon to the server and he would see the email you sent. There are three computers here: the client computer, which you use, the server computer and another client computer, which the email receiver uses.

The focus in this series is on the email message format, and not on the network of computers or movement of email from one computer to the next.

Example Email
Imagine that you were to type your email in a text editor. Also imagine that what you type is what has to be sent through the Internet wire from the client computer to the server computer. The following is an example of what you would type:

From: John Smith <jsmith@myserver.com>
To: Mary Taylor <maryt@herserver.net>
Subject: Payment of Dues
Date: Fri, 21 Nov 2010 09:55:00 -0000
Cc: The President <president@boss.com>
Bcc: Police <pol@theaudit.com>

Dear Madame,
I am by this email reminding you to pay your dues. I also want to let you know that an email message is made up of lines, and after each line you must press the enter key of your keyboard if you are typing the email in a text editor and if the email will be sent as typed, through the Internet without modification.
Sincerely,
John Smith
.

Email Outline
An email message is made up of lines of characters. These lines are grouped into two sections: the header section of the message and the body of the message. The header section is separated from the body by a blank line. To achieve this you have to press the enter key of the keyboard twice just as you finish typing the last line of the header, if you are typing the email in a text editor and if the email message will be sent through the Internet, without modification. You can clearly see the header section and the body of an email message in the above sample. An email message consists of the header section and the body. The body is optional. So you can actually send an email that has only the header section.

Each line you type should not be more than 78 characters long. So each header line should not be more than 78 characters long and each body line should not be more than 78 characters long. These 78 characters include the space characters created by pressing the spacebar on the keyboard.

In this part of the series I assume that you are typing your email with a text editor and the email will be sent through the Internet without modification. So a line is achieved when you press the enter key of the keyboard. So while typing you should be counting the characters and you press the enter key as soon as you have typed 78 characters. Some lines are shorter than 78 characters. In that case you press the enter key after typing the short line. 78 is the upper limit of a line. Most header lines are naturally shorter than 78 characters.

In the body of the email, paragraphs are separated by blank lines. In each paragraph no line is longer than 78 characters. To achieve a blank line with your text editor, press the enter key twice (just as you finish typing the last line). In email, a sentence is not a line. A line can be made up of more than one sentence; but a line should not be more than 78 characters long. A sentence can be split in two lines in a paragraph. Note: in other forums a paragraph is a line, but not with emails.

A blank line is achieved when you press the enter key twice at the end of a previous line; technically, when you do this, the second line (press) is a line of zero length, still shorter than 78 characters, as required. After the header section you need a blank line; the other possible blank lines in the message body do not cause any wrong interpretation of the structure of the email.

When you press the enter key, you insert the internal characters, “\r\n” in your text editor. You do not see these characters as you type. In some operating systems it is just “\n” that is inserted (you do not see it). These internal characters are not part of the 78 characters.

The message body has the personal information you want to send, while the header has technical information such as the email address.

The Header Section
Each line in the header section is called a field and it is made up of two parts: the field name and the field body. These two parts are separated by a colon (:). The word, body is used in two places in the email message: you have a header field body and the message body.

In the above sample, there are six header lines and so six field names and six field bodies. The six field names are From, To, Subject, Date, Cc, and Bcc

The From Field
An example of the From field is,

    From: John Smith <jsmith@myserver.com>

You begin with the word, From. This is followed by a colon. After this colon, you can have the actual name of the person who is writing the mail. The presence of this name is optional. After the optional name you must have the email address of the person writing the mail in angle brackets. After typing any header field you must press the enter key.

The To Field
An example of the To field is,

    To: Mary Taylor <maryt@herserver.net>

You begin with the word, To. This is followed by a colon. After this colon, you can have the actual name of the person who will receive the mail. The presence of this name is optional. After the optional name you must have the email address of the person who will receive the mail in angle brackets.

The Subject Field
An example of the Subject field is,

    Subject: Payment of Dues

You begin with the word, Subject. This is followed by a colon. After this colon, you have the text for the subject of the message body content.

The Date Field
An example of the Date field is,

    Date: Fri, 21 Nov 2010 09:55:00 -0000

You begin with the word, Date. This is followed by a colon. After this colon, you have the text for the Date and time the person writes the email. This text must be in a special format. In this article I give you the format for U.S.A. For simplicity we assume that the date and time you will type here is what you read from your wristwatch or clock.

You begin the text with one of the following days of the week:  Mon, Tue, Wed, Thu, Fri, Sat and Sun; each is three letters long. After this you have the comma. Then a space and then the day number of the month. You have a space again and then one of the months of the year in three letters: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec. Then you have a space and the year in 4 digits.

After the year you have a space and then the time. For this article the date and time is what you read from your wristwatch and type. This is called the local time. Of course the time on your wristwatch should be correct. You begin the time with the hour in two digits - the 24-hour clock (any number less than ten begins with zero). Next you have a colon. After the colon you have the minutes in two digits (any number less than ten begins with zero). Then you have a colon again and then two zeros. Allow these two zeros for simplicity as you can have other digits there. Then you have a space, the negative sign and then four zeros. Let us allow this last section as it is for simplicity as you can also have a plus sign with four other digits.

The Cc Field
When you send an email to a person, you may also wish to send a copy of the same email to another person. Cc stands for carbon copy. An example of the Cc field is,

    Cc: The President <president@boss.com>

You begin with the word, Cc. The rest of the syntax in the field is as in the case of the To field.

The Bcc Field
Bcc stands for Blind Carbon Copy. When you send an email to somebody, you can choose to send a copy to another person. Both the primary recipient and the person who gets the copy will be aware that both of them have read the same information. It is possible to send another copy to a third person and neither the primary recipient nor the person who officially gets the copy would know that a third person has received a copy. You use the Bcc field for this purpose. The person whose email address is in the Bcc field will know that you have sent the email to the primary recipient and a copy to somebody, but neither the primary recipient nor the copy receiver would know the person who has received a Bcc copy; neither may even know that a Bcc person even exists (while he exists).

An example of the Bcc field is,

    Bcc: Police <pol@theaudit.com>

You begin with the word, Bcc. The rest of the syntax in the field is as in the case of the To field.

Obligatory Header Fields
From the Email specification, an email must have a From and a Date field. The other header fields are optional. You and me know that if there is no To field the email will not arrive "anywhere". So, let us say that an email should have at least three header fields, which are the From, To and Date fields.

Order of Header Fields
You can type the header fields in any order, not necessarily in the order given in the above sample. For example you can start by typing the Date field, then the To and then the From field; and the rest still in any order. The three fields mentioned can still be typed in any order and have other fields between them. Just remember that after typing a header field, you have to press the enter key.

Multiple Email Addresses
Apart from the Date and Subject fields above, each of the fields can have more than one email address. In each of the field body, you separate the addresses with commas. The following sample illustrates this:

From: <onef@onef.com>, <twof@one.com>, <threef@onef.com>
To: <onet@onef.com>, <twot@onef.com>, <threet@onef.com>
Subject: Payment of Dues
Date: Fri, 21 Nov 2010 09:55:00 -0000
Cc: <onec@onef.com>, <twoc@onef.com>, <threet@onec.com>
Bcc: <oneb@onef.com>, <twob@onef.com>, <threeb@onef.com>

Dear Colleagues,

We are by this email reminding you to pay your dues. We also want to let you know that an email message is made up of lines, and after each line you must press the enter key of your keyboard if you are typing the email in a text editor and if the email will be sent as typed, through the Internet without modification.

Sincerely,
Higher-Up Team
.

Note the use of the commas in the above sample. Also note in the above sample that the optional email names that would precede email addresses are not given. This time the message body has blank lines to create paragraphs. The blank line between the header section and the body still has to be there.

In the above email samples the message body lines may not respect the 78 characters limit. This is because I did not have the time to count the characters.

Note, the email content ends with a full stop on a separate line.

Time to take a break. Let us stop here for this part of the series. We continue in the next part.

Chrys

Related Links

ECMAScript Basics
ECMAScript Operators
Expressions in ECMAScript
Statements in ECMAScript
Custom Objects in ECMAScript
Functions in ECMAScript
ECMAScript Date Object
The ECMAScript String Object
ECMAScript String Regular Expressions
ECMAScript Template Literal
The ECMAScript Array
ECMAScript Sets and Maps
ECMAScript Number
Scopes in ECMAScript
Mastering the ECMAScript (JavaScript) eval Function
Sending Email with ECMAScript
ECMAScript Insecurities and Prevention
Advanced Course
Advanced ECMAScript Regular Expressions
Promise in ECMAScript 2015
Generator in ECMAScript 2015
ECMAScript Module
More Related Links
Node Mailsend
EMySQL API
Node.js Web Development Course
Major in Website Design
Low Level Programming - Writing ECMAScript Module
ECMAScript Course

NEXT

Comments

Become the Writer's Follower
Send the Writer a Message