Transcript from the "SMTP" Lesson
>> Now that we've had some time to play around with HTTP servers and did a little bit with headers and netcat and curl, can talk a little bit about some other text based fun protocols like SMTP. SMTP is used to send emails. So, for example, we can send an email on our local SMTP daemon which on my system is running.
[00:00:24] I don't know how common that is on Macs, but I don't know, give it a shot, maybe it'll work. If not, you can just see how it works on my machine. So we can send a message from whoever we want, because SMTP servers typically have no validation at all by default.
[00:00:40] Although if you try to do this on a real SMTP server on the public internet, it's not going to work. So, it's kind of fun to do on localhost. So, here I can connect to localhost port 25. Email is just a simple text based protocol. It actually has a lot of commonality with HTTP.
[00:01:01] So, it has things like status codes, it has things like in the body of messages, you have a similar idea to HTTP headers. It has similar kind of content mime system. So I can do, hello localhost. Let me get back message that's 200 category message that means okay, now I can send email from whoever I want.
[00:01:31] So I send one from email@example.com. Sorry mail from, not fom firstname.lastname@example.org 250 OK. So the server seems to be fine with this, even though just sending it from netcat locally. I can send rcpt to substack@localhost. So this is gonna send me an email locally. Accepted as well. Now you can send the data, the body of the email message with data commands.
[00:02:08] And then by default, you type everything you want to type and then you hit a period. You type a period on a single line. So you hit period, Enter. And then that's like the end of the message. There's other ways of formatting it but this is the default way.
[00:02:23] That's very old. So by default most email clients are going to interpret the first block just like HTTP is the headers. So one is called subject. You can also have things like different things in there. So, FAKE NEWS and two new lines just like HTTP and you're fired.
[00:02:46] So there we go, it was sent. Okay, and we can quit. And now I have new mail on my system so I can type the mail command to read it. Here we go email@example.com. Get a message, you're fired. So this is all that it takes to send a message to an SMTP server.
[00:03:08] Although in the real internet, the servers are very careful to check what IP address they're actually receiving the messages from so that they have some more verification than just accepting anything blindly. Which is actually how email used to work on the public internet back when everyone was an academic or worked for the military, I guess.
[00:03:29] So just something kind of fun another text based protocol. That's, you can type out with netcat if you ever just want to poke around.