Receiving and storing emails are optional
Components:
Say you have a Postfix mail server and you want to send an email using the command below
echo "This is a test email body" | mail -s "Test Subject" [email protected]
mail command is a Mail User Agent (MUA)Flow example (reference):
| Step | Role interaction | Typical ports |
|---|---|---|
| MUA → MSA/MTA (submission) | Mail User Agent → Mail Submission Agent or Mail Transfer Agent | 587 (submission) or 465 (SMTPS) |
| MTA → MTA (relay) | Mail Transfer Agent → Mail Transfer Agent | 25 (SMTP) |
| MTA → MDA (local delivery) | Mail Transfer Agent → Mail Delivery Agent | If local same-host: none |
| MUA → MDA (retrieval) | Mail User Agent → Mail Delivery Agent (IMAP/POP3 server) | 143/993 (IMAP), 110/995 (POP3) |
DKIM and SPF can be compared to a business license or a doctor's medical degree displayed on the wall of an office, they help demonstrate legitimacy. DMARC tells mail servers what to do when DKIM or SPF fail, whether that is marking the failing emails as "spam," delivering the emails anyway, or dropping the emails altogether
SPF, DKIM, and DMARC records are stored in the Domain Name System (DNS), which is publicly available. All stored as DNS TXT records
SPF (Sender Policy Framework): Specifies which servers can send emails for your domain. The recipient checks your DNS SPF record to verify the sender’s IP. Helps prevent spoofing but can break when emails are forwarded

DKIM (DomainKeys Identified Mail): Adds a cryptographic signature to verify that an email hasn’t been altered and was sent from an authorized domain. Uses a private key to sign and a public key (in DNS) for verification

DMARC (Domain-based Message Authentication, Reporting & Conformance): Builds on SPF and DKIM to define how to handle emails that fail authentication. It enforces alignment between visible “From” domains and sending domains and provides reports for visibility

Recommended video: https://youtu.be/c9fLp5uIxp8?si=oW177lYN_l-apV_-