SMTP

In notebook:
FrontEndMasters Networking and Streams
Created at:
2017-09-23
Updated:
2017-09-23
Tags:
backend

smtp

smtp is the protocol used to deliver email messages.

Here we can send an email from trump@whitehouse.gov to substack@localhost.

The lines that start with a number are messages from the server.

On his Linux system, he has a running SMTP deamon.

By default, SMTP servers have no validation at all.

So he can send any email from any address, but it would not work on a public server.

Email is text based protocol similar to HTTP. It has status codes, body/content mime system.


$ nc localhost 25
220 zzz ESMTP Exim 4.84_2 Tue, 02 May 2017 21:29:36 -0700
helo localhost
250 zzz Hello localhost [127.0.0.1]
mail from: trump@whitehouse.gov
250 OK ☛ means the server accepted the message
rcpt to: substack@localhost ☛ this will send an email locally
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Subject: FAKE NEWS

You're fired.
. ☛ this means the message is ended (period + ENTER)
250 OK id=1d5lvL-00026H-DW ☛ sent ok
quit
221 zzz closing connection

Since this email was sent locally, I can read the message with the mail command:

$ mail
Mail version 8.1.2 01/15/2001.  Type ? for help.
"/var/mail/substack": 1 message 1 new
>N  1 trump@whitehouse.  Tue May 02 21:30   16/491   FAKE NEWS

Seems legit:

& n
Message 1:
From trump@whitehouse.gov Tue May 02 21:30:09 2017
Envelope-to: substack@localhost
Delivery-date: Tue, 02 May 2017 21:30:09 -0700
Subject: FAKE NEWS
From: trump@whitehouse.gov
Date: Tue, 02 May 2017 21:30:05 -0700

You're fired.

On the real Internet, the servers verify the IP address of where they receive the message from. But originally the email servers accepted any messages blindly.