I don't mean SMTP/IMAP clients, I mean a working SMTP server that can both receive and send email.
There are lots of examples of partial PHP and Go SMTP servers that only listen for SMTP connections - aren't there any which show how to send mail?
I'm really interested in learning this second half of the Simple Mail Transfer Protocol. I understand that there are a lot of bad servers which vary from the standard - but I want to learn how the whole protocol from start to finish is implemented.
I think you misunderstand how SMTP is supposed to work. Here is a simplified version:
The Mail User Agent (MUA) queues a message for delivery by sending it to the Mail Submission Agent (MSA).
MSA connects to the Mail Transfer Agent (the "smtp server") over SMTP.
The MTA then uses DNS to lookup the MX record for the recipient's domain. It then contacts the recipient's MX server as a SMTP client.
The MX server accepts the envelope; it then forwards it to a Mail Delivery Agent (MDA).
MDA then puts the envelope in some message store where some IMAP or POP3 server reads messages. The MUA then connects to these servers to retrieve the message.
The entire process uses three main commands. MAIL
, RCPT
and DATA
.
MAIL
= Envelope information, bounce addresses, etc.RCTP
= The recipient.DATA
= The payload.The SMTP server responds - much like HTTP actually, with error codes and based on that, the MTA knows what to do with the envelope (its a bounce back, so send appropriate reply, etc.)
In this process there is no such thing as "retrieve email" (ignoring ETRN
for a bit); as SMTP is purely for email transmission and not retrieval.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With