SMTP

About this post

This post is a follow-along of the scenario in Computer Networking: a Top Down Approach, 8th Edition. I added some extra steps to make it work with our department’s mail server.

Find the mail server

Use nslookup to find the mail server of a domain.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
~ % nslookup 
> SET TYPE=MX
> csie.ntu.edu.tw
Server: 192.168.1.1
Address: 192.168.1.1#53

Non-authoritative answer:
csie.ntu.edu.tw mail exchanger = 1 mx1.csie.ntu.edu.tw.
csie.ntu.edu.tw mail exchanger = 2 mx2.csie.ntu.edu.tw.

Authoritative answers can be found from:
csie.ntu.edu.tw nameserver = csman.csie.ntu.edu.tw.
csie.ntu.edu.tw nameserver = ntuns.ntu.edu.tw.
csie.ntu.edu.tw nameserver = csman2.csie.ntu.edu.tw.
mx1.csie.ntu.edu.tw internet address = 140.112.30.163
mx2.csie.ntu.edu.tw internet address = 140.112.30.164
csman.csie.ntu.edu.tw internet address = 140.112.30.13
csman2.csie.ntu.edu.tw internet address = 140.112.30.14

so here I use mx1.csie.ntu.edu.tw as the mail server.

Send email using telnet

Note that on the textbook, there’s no specification of FROM, TO, and SUBJECT fields, but one of my friend tried it and the email got filtered as spam. Therefore, these fields are added to make it work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
~ % telnet mx1.csie.ntu.edu.tw 25
Trying 140.112.30.163...
Connected to mx1.csie.ntu.edu.tw.
Escape character is '^]'.
220 mx1.csie.ntu.edu.tw ESMTP Postfix
HELO crepes.fr
250 mx1.csie.ntu.edu.tw
MAIL FROM: <alice@crepes.fr>
250 2.1.0 Ok
RCPT TO: <your_id@csie.ntu.edu.tw>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
From: alice@crepes.fr
To: your_id@csie.ntu.edu.tw
Subject: meow
hello world!
.
250 2.0.0 Ok: queued as 0560F1173A98

Result

mail
Here, it can be seen that although I used alice@crepes.fr as the sender, from SPF, it’s actually sent by mx1.csie.ntu.edu.tw, which is the mail server of NTU CSIE, not from some server in France.