I have a very hard time to understand how SMTP works.
I've read already:
- Message Submission for Mail
- Internet Mail Architecture
- Internet Message Format
- Simple Mail Transfer Protocol
I know the SMTP server listens on PORT 25 and exchanges commands with the client.
Lets assume I own the domain mydomain.com and have there my own implemented SMTP server running.
Somebody want sent me (for example [email protected]) an email.
On My server I will see traffic like this:
Server Response: 220 mydomain.com SMTP
Client Sending : HELO domain.com
Server Response: 250 Hello domain.com
Client Sending : MAIL FROM: <[email protected]>
Server Response: 250 Ok
Client Sending : RCPT TO: <[email protected]>
Server Response: 250 Ok
Client Sending : DATA
Server Response: 354 End data with <CR><LF>.<CR><LF>
Client Sending : Subject: Example Message
Client Sending : From: [email protected]
Client Sending : To: [email protected]
Client Sending :
Client Sending : Yo,
Client Sending :
Client Sending : Sending a test message.
Client Sending :
Client Sending : Later,
Client Sending : Carl
Client Sending : .
Server Response: 250 Ok: queued as 45334
Client Sending : QUIT
Server Response: 221 Bye
So my server has now the array of bytes containing the message somewhere in memory.
Question:
What I should do now with this message ? (assuming the recipient is on my machine - no relaying is needed)
For the mail to be delivered to the user mailbox, you need a mail delivery agent or MDA.
Read more here: https://en.wikipedia.org/wiki/Mail_delivery_agent