MX record

A DNS ‘mail exchange’ (MX) record directs email to a mail server.

SMTP

SMTP is for sending data, works between servers to transfer information or client to server

SMTP is used to push emails from one computer to another. Usually this is between two servers but a client can also push an email to a server. IMAP is a protocol to allow a client to browse and move emails on a remote server.

IMAP

IMAP is used to retrieve messages

When you send an email your client will contact the server you have configured using SMTP. The server will first validate the client, checking the username and password. Then the client transfers the email to the server, the server will check that the From header is an address you are authorized to send from. The server will then look at the To header, in addition to the CC and BCC headers to get the domains of the destination. It does a domain lookup to find the MX record for that domain and then connects to this server using SMTP. The server does some verification of the other server and then allow it to send the email. Again it will do further steps to check that the server can actually send email from you before accepting the email. Part of this is to scan the email to check if it is spam or contains a virus. When the email is accepted it is put into the receiving users inbox, there may be some filters applied first if the user have configured those. The end user will eventually log into the email server using IMAP. It will see the received email and can read it. The IMAP protocol will allow the client to set the email as read once the user opens it and then move it to another folder if the user wants that, for example when deleting the email. But the email still remains on the server until deleted.

What is email spoofing? | Cloudflare | Cloudflare