How SMTP (receiving emails) works

network-protocolssmtp

I have a very hard time to understand how SMTP works.

I've read already:

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 bob@mydomain.com) 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: <me@domain.com>
Server Response: 250 Ok
Client Sending : RCPT TO: <bob@mydomain.com>
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: me@domain.com
Client Sending : To: bob@mydomain.com
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)

Best Answer

For the mail to be delivered to the user mailbox, you need a mail delivery agent or MDA.

A mail delivery agent or message delivery agent (MDA) is a computer software component that is responsible for the delivery of e-mail messages to a local recipient's mailbox. Also called an LDA, or local delivery agent. Within the Internet mail architecture, local message delivery is achieved through a process of handling messages from the message transfer agent, and storing mail into the recipient's environment (typically a mailbox).

Read more here: https://en.wikipedia.org/wiki/Mail_delivery_agent