Email Agent infrastructure
Let's start with the basic components of an email system before we dive into any details:
- all - Overview
- MxAReceive - (A) Email from external sender to local recipient
- MxASendLocal - (B) Email from local sender to local recipient
- MxASendExternal - (C) Email from local sender to external recipient
- MxADownload - (D) Read E-Mails
(A) Email from external sender to local recipient
The MTA (Mail Transfer Agent) listens on port 25 for incoming SMTP connections. Once an email arrives the MTA usually does antivirus, antispam, recipient and other important checks before the email is passed to the MDA (Mail Delivery Agent). Another commonly used term for MDA is LDA (Local Delivery Agent). Often an MDA does some filtering with an additional component like sieve. Finally the email is stored into mailbox. There are two commonly used mailbox formats:
- mbox: holds all emails in one file
- maildir: file folder with a file for each email
(B) Email from local sender to local recipient
The MSA (Mail Submission Agent) listens on port 587 for incoming SMTP AUTH connections. Usually locale users are allowed to send emails. Is a client program properly configured with server url, username, password and encryption the MSA will accept incoming email from this MUA. After a few checks the email is passed to the MTA (Mail Transfer Agent). As the recipient is a local user the MTA passes the email to MDA. Further email flow is like described in (A). Good to know:
- SMTP Auth is important for SPF and DKIM!
- Filters in MTA and/or MDA are often configured differently for external sender (A) and local sender (B)
(C) Email from local sender to external recipient
This case is very similar to (B) but sender is an external address. Once the MTA receives the email it will be send to an external MTA server.
(D) Read E-Mails
So far everything was processed by the server. If it comes to read emails we need a client program MUA (Mail User Agent). There are two protocols for the client to communicate with the server: IMAP and POP3. POP3 copies every email to the client whereas IMAP leaves the email on the server. The data can optionally be encrypted with STARTTLS IMAP(143)/POP3(110) or the connection is encrypted IMAPs(993)/POP3S(995). Communication in plaintext (no encryption) is often not allowed.
Conclusion
Basic email agent infrastructur is easy to understand. Those four cases are just a few of many! In real life things can get very complicated but it's important to a have simple overview which is easy to understand.