[Here we start] How is an email sent? -- Domain, Nameserver and 'MX' Record

This is the first tutorial of all. Here we start learning about a 'domain'.

An email address looks like this:

example@domain.com

Suppose that you are example@gmail.com, writing an email to me, tzchz@hotmail.comWhen clicking the 'Send' button, have you ever thought about how it is sent?

You may remember the description in the textbook when studying in school:

When a user of Google Mail sends an email to a user of Microsoft Hotmail, Google's server will transport the mail to Microsoft's server, and then Microsoft delivers the mail to the receiver.

When reading this, did you imagine that there must be something like a 'contract' between Google and Microsoft so that Google can transport the mail to Microsoft?

In fact, mail servers are much easier to deploy, but there does be a 'contract'. It's called Domain Records

The part after '@', 'hotmail.com' -- popularly called a 'URL', is a Domain (Domain Name). Every Domain has its corresponding Nameserver. Like a 'phone book', Nameservers lists where the servers corresponding to the Domains is, while the server addresses are called Records. Each Record has a different type, and the 'MX' one tells the location of the Mail server.

Now, let’s go back to the example at the beginning. You are sending an email from example@gmail.com to me, tzchz@hotmail.com. After clicking 'Send', the server of gmail.com looks up the Nameserver of hotmail.com. According to the Nameserver, the 'MX' Record of hotmail.com is 'hotmail-com.olc.protection.outlook.com', so Google Mail sends the mail there, and Microsoft Hotmail receives it and delivers it to me.

However, have you also considered the problem of avoiding phishing mails? When an email is transported from Google Mail to Hotmail, how does Hotmail confirm if it is from Google Mail? There is another Record type called 'SPF'. Contrary to the 'MX' record, the 'SPF' record tells the receiver where the sender is.

In the example, when Hotmail receives your email from Google Mail, it looks up the 'SPF' record of gmail.com, and check if the sender's address is listed in the 'SPF' record.

That's how 'MX' and 'SPF' Records work when sending emails. Tomorrow, we'll learn about 'A' and 'CNAME' Records, which help you visit thousands of websites via a browser.