EML Cheat Sheet
1. Workflow (do it in this order, every time)
- Integrity first: check the hash of the delivered file (
md5sum c7-email.zip/sha256sum), compare with the given value, and note it in the report. - Open the raw file in a text editor (never only a mail client). Note the top-level
Content-Type. - Overview:
From,To,Cc,Reply-To,Return-Path,Subject,Date,Message-ID. - Routing: read
Received:headers bottom to top. Per hop write down: FQDN, IP, protocol (with ...), timestamp. - Trust boundary: only headers added by servers you trust (your own provider, topmost block) are reliable. Everything below can be forged.
- Authentication:
Authentication-Results,Received-SPF,DKIM-Signature,ARC-*. Check alignment ofFromdomain,Return-Pathdomain and DKIMd=. - Who owns the IPs? WHOIS / AS lookup per hop (country, owner). This is the evidence for “where is the server”.
- Encryption: E2E (MIME structure), transit (
ESMTPS, TLS version/cipher), at rest (only provider claims, e.g. vendor headers). - Body/attachments: decode, list real URLs, hash attachments, never open outside an isolated VM.
- Report: for every claim give header line + source, plus the command/tool used. No “probably” without evidence.
Quick grep set:
grep -n -i -E "^(Received|Authentication-Results|Received-SPF|DKIM-Signature|ARC-|X-|Return-Path|From:|To:|Reply-To|Message-ID|Date:|Content-Type|Content-Transfer)" mail.eml | cut -c1-160
2. EML structure
An .eml is plain text (RFC 5322): headers, one blank line, then the body. Long headers are folded: continuation lines start with a space or tab.
Header-Name: value
Header-Name: value
<- blank line = end of headers
body (possibly MIME multipart)
MIME basics
| Header | Meaning |
|---|---|
MIME-Version: 1.0 | MIME is used |
Content-Type | Type of the (part of the) body, may carry boundary= and charset= |
Content-Transfer-Encoding | 7bit, 8bit, base64, quoted-printable. An encoding, not encryption. |
Content-Disposition | inline or attachment; filename=... |
Content-ID | Referenced from HTML as cid:... (embedded images) |
Common MIME types
| Type | What it means |
|---|---|
text/plain, text/html | Readable body (HTML is where links and tricks live) |
multipart/alternative | Same content in several forms (plain + HTML) |
multipart/mixed | Body + attachments |
multipart/related | HTML + embedded resources (inline images) |
multipart/signed | Signed only (S/MIME application/pkcs7-signature, PGP application/pgp-signature) |
multipart/encrypted | PGP/MIME encrypted (application/pgp-encrypted) |
application/pkcs7-mime; smime-type=enveloped-data | S/MIME encrypted (.p7m) |
application/octet-stream, application/zip, message/rfc822 | Binary, archive, or an attached email |
Decode a base64 part:
base64 -d part.txt > part.html
# or with Python: msg.get_body(preferencelist=("html","plain")).get_content()
Boundary logic: parts are separated by --boundary, the end is --boundary--.
3. Header elements
Address headers (two levels)
| Level | Fields | Notes |
|---|---|---|
| Envelope (SMTP) | Return-Path (MAIL FROM), Received ... for <rcpt> | What servers really used; bounces go to Return-Path |
| Display | From, To, Cc, Reply-To, Sender | Freely settable. Bcc never appears. |
Mismatch between From, Return-Path, Reply-To and DKIM d= is a classic indicator.
Received: anatomy
Received: from HELO-name (rDNS-name [IP])
by receiving-server (software) with PROTOCOL id QUEUEID
for <envelope-rcpt>; Date
- Each server prepends one. Bottom = first hop, top = last hop.
from: sender side. The HELO name is self-declared (forgeable). The IP in[ ]is observed by the receiver.by: the server that wrote this line.- Chain check:
byof one hop should matchfromof the hop above it. - Check timestamps increase plausibly (time zones differ per server, convert to UTC).
with protocol values
| Value | Meaning |
|---|---|
SMTP | Plain SMTP |
ESMTP | Extended SMTP (no TLS logged) |
ESMTPS | ESMTP with TLS |
ESMTPA | ESMTP with authentication (submission) |
ESMTPSA | TLS and authentication (typical first hop from a client) |
LMTP | Local delivery to a mailbox, usually last internal hop, often not TLS |
HTTP / HTTPS | Submitted via webmail/API |
ESMTP without S does not prove plaintext, only that no TLS was logged.
Other useful headers
| Header | Why it matters |
|---|---|
Message-ID | Domain part should fit the sending infrastructure |
X-Originating-IP | Client IP (if present, often stripped) |
X-Mailer / User-Agent | Software used. Shows the mailer, not the server location. |
X-Received | Google internal hops, rarely useful for attribution |
X-Sieve, X-Sieve-Redirected-From | Sieve (Dovecot Pigeonhole) filter ran. The second header indicates a redirect rule forwarded the mail (value is probably the original mailbox). Typical reason for “mail arrived at the wrong recipient”. |
Delivered-To, X-Original-To | Final or original recipient as seen by the MTA |
X-Pm-* (Proton) | e.g. X-Pm-Content-Encryption: on-delivery (my reading: Proton encrypts at rest on delivery, verify), X-Pm-Transfer-Encryption (TLS info) |
X-MS-Exchange-*, X-Microsoft-Antispam | Microsoft 365 internals and spam scoring |
X-Spam-* | Spam scoring by the receiving side |
List-Unsubscribe | Mass mailing indicator |
Only trust vendor headers that sit in the topmost block, written by your own provider.
4. SPF, DKIM, DMARC, ARC and others
Where each acts
Sender client -> sender's outbound server -> internet -> receiver's inbound server -> mailbox
signs DKIM checks SPF/DKIM/DMARC,
writes Authentication-Results, ARC-*
SPF (RFC 7208)
- Question: Is the connecting IP allowed to send for the envelope domain?
- Checked against
Return-Path(MAIL FROM) domain, or HELO. - DNS:
dig +short TXT domain.tld->v=spf1 include:... ip4:... -all - Results:
pass,fail,softfail(~all),neutral,none,temperror,permerror - Look for:
Received-SPF:orspf=... smtp.mailfrom=...inAuthentication-Results. - Breaks on forwarding (the forwarder’s IP is not authorised).
DKIM (RFC 6376)
- Question: Was the message signed by the domain and not altered?
- Header
DKIM-Signature:
| Tag | Meaning |
|---|---|
v=1 | Version |
a= | Algorithm (rsa-sha256, ed25519-sha256) |
d= | Signing domain |
s= | Selector (names the DNS key) |
h= | Signed headers (should contain From) |
bh= | Body hash |
b= | Signature |
c= | Canonicalization (relaxed/relaxed, simple/simple) |
t= | Signing time (Unix epoch seconds) |
x= | Expiry time (epoch seconds, optional) |
- Public key:
dig +short TXT <selector>._domainkey.<d> - Selector names often hint at the provider (e.g.
zmail,google,selector1). - Survives forwarding if the message is unmodified. Mailing lists that modify subject/body break it.
- Full verification:
dkimverify < mail.eml(from thedkimpypackage, from memory).
DMARC (RFC 7489)
- Question: Do SPF or DKIM pass and align with the visible
From:domain? What should the receiver do if not? - DNS:
dig +short TXT _dmarc.domain.tld - Tags:
p=policy (none/quarantine/reject),sp=subdomain policy (inheritsp=if absent),rua=/ruf=reports,pct=percentage,adkim=/aspf=(rrelaxed,sstrict). - Pass = (SPF pass and aligned) or (DKIM pass and aligned).
- A lookalike domain can pass all three. A pass proves authorisation by that domain, not honesty.
ARC (RFC 8617)
- For forwarders and mailing lists: preserves the original auth results.
- Three headers per instance
i=1,2,...:ARC-Authentication-Results,ARC-Message-Signature,ARC-Seal(withcv=). cv=noneati=1,cv=passafterwards,cv=fail= broken chain. Instances must be gap-free.- Only meaningful if you trust the sealing domains.
Others
| Standard | Where | Notes |
|---|---|---|
| S/MIME | multipart/signed; protocol="application/pkcs7-signature", smime.p7s | Check signer certificate, chain, and that cert email matches From. openssl cms / openssl smime -verify (check flags for your version) |
| PGP | multipart/signed; protocol="application/pgp-signature" or -----BEGIN PGP ...----- | Check key ID/fingerprint |
| BIMI | BIMI-Selector, BIMI-Location | Logo display, only meaningful with enforced DMARC |
| MTA-STS / DANE / TLS-RPT | DNS only | Force TLS between domains, not visible in the .eml |
| Autocrypt | Autocrypt: | Only advertises a public key, does not mean encrypted |
Reading Authentication-Results
Authentication-Results: mx.receiver.tld;
spf=pass smtp.mailfrom=sender.tld;
dkim=pass header.d=sender.tld header.s=sel1;
dmarc=pass header.from=sender.tld
Use the topmost one added by your own provider. No auth headers at all = unverified, not clean.
5. Encryption: the three questions
| Question | Visible in the .eml? | Where to look |
|---|---|---|
| 1. End-to-end (sender to receiver) | Yes | Top-level Content-Type: multipart/encrypted or pkcs7-mime enveloped-data = encrypted. Readable text/html + base64 = not E2E. multipart/signed = signed only. |
| 2. In transit between MTAs | Partly | with ESMTPS, version=TLSv1.x cipher=... per Received. Name the TLS version and cipher. Hops without S: “not documented”. |
| 3. At rest on each MTA | No (only provider claims) | Possibly a vendor header on the last hop (e.g. Proton X-Pm-Content-Encryption). All other MTAs: unknown. |
Pitfalls:
- Base64 is not encryption.
- A client can export an .eml after decrypting, so check that the
Receivedchain is still there. - TLS protects only the link, every MTA can read the content.
- Say “not determinable” instead of “not encrypted” when the file has no evidence.
6. Where is the server? (evidence for “outside Switzerland” type tasks)
- Take the IP from the sending hop’s
[ ], not the HELO name. - Look up the owner: WHOIS / AS lookup (e.g.
whois <ip>,dig +short -x <ip>, or a site such as bgp.he.net, networksdb.io). - Collect corroboration: DKIM
d=/s=, ARC sealing domain, SPFinclude:, MX records of the domain,Message-IDdomain. - Mention time: DNS/hosting can change, so state when the evidence applies (e.g. date in the mail vs. today).
- Write: IP -> range -> AS number -> owner -> country. No “probably”.
7. Common attacks and disguises
Header level
| Trick | How to spot it |
|---|---|
Spoofed From: | SPF/DKIM/DMARC fail or misaligned, Return-Path/Reply-To differ |
| Display-name spoofing | "CEO Name" <random@freemail.tld>: check the real address |
| Lookalike domain / homograph | paypa1.com, rn vs m, IDN/punycode (xn--...) |
Forged Received: lines | Sit below the trust boundary, rDNS/IP don’t match, by/from chain breaks, impossible timestamps, hop IP owned by an unrelated network |
Forged Authentication-Results or vendor headers (X-Spam-Status: No) | Appear below your own provider’s headers, or the authserv-id isn’t your provider |
Fake X-Sieve-Redirected-From / X-Pm-* | Same: outside the topmost trusted block |
| Wrong clock / date games | Date years off, hops with inconsistent time zones: re-injection, restored archive, broken NTP, or forged |
| Reply-To hijack | Reply goes to the attacker although From looks legit |
| Thread hijacking | Real conversation (In-Reply-To, References) taken over from a compromised mailbox |
| Open relay / compromised account | Passes SPF/DKIM from a legit server, but content and behaviour are abnormal |
Body / HTML level
| Trick | Notes |
|---|---|
Link text != href | Compare visible text with the real URL in the HTML source |
| Open redirect | Trusted domain https://good.tld/redirect?url=evil as a decoy |
| URL shorteners / tracking links | Hide the target, abused newsletter links |
Fragment parameters (#?act=...) | Part after # is never sent to the server, read by client-side JS |
| HTML smuggling | JavaScript builds the payload in the browser, no file for the gateway to scan |
HTML forms in mail (<form>, <input>, <select>, hidden fields) | Data posted to an attacker server. Some clients block it, some don’t. Look at action=. |
| Hidden text / zero-size, white-on-white | Pushes spam filters off, hides filler text (often junk “verification code” text) |
| Tracking pixel / remote image | 1x1 image confirms the address is live and leaks IP, user agent, time |
cid: / inline images | Text rendered as an image to dodge text filters (QR code phishing) |
| Look-alike hosting on trusted platforms | S3, SharePoint, Google Drive, Dropbox, Cloudflare Workers: domain reputation is high |
<base href>, <meta refresh>, JavaScript | Redirects and rewrites links |
Attachments
- Macro Office files, ISO/IMG/ZIP containers (can bypass Mark-of-the-Web), password-protected ZIP (password in the mail body), double extensions (
invoice.pdf.exe),.lnk,.html,.svg,.iso. - Hash them:
sha256sum file, then look up the hash (VirusTotal etc.). Analyse only in an isolated VM.
Social engineering patterns
Urgency/authority (invoice, delivery, locked account), BEC/CEO fraud, thread hijacking, fake “verification code” or “registration confirmation”.
MITRE ATT&CK (recalled, verify IDs in your ATT&CK version)
T1566 (.001 attachment, .002 link, .003 via service), T1598 phishing for information, T1027 obfuscated files (HTML smuggling).
8. Bash: timestamps and UTC
DKIM t= and x= are Unix epoch seconds (UTC).
# GNU date (Linux): epoch -> UTC
date -u -d @1700000000
date -u -d @1700000000 +"%Y-%m-%dT%H:%M:%SZ"
# macOS / BSD date
date -u -r 1700000000
# Extract t= from a DKIM-Signature in a file and convert (GNU grep/date)
t=$(grep -m1 -i -A5 '^DKIM-Signature' mail.eml | grep -o -E '\bt=[0-9]+' | head -1 | cut -d= -f2)
date -u -d @"$t" +"%Y-%m-%d %H:%M:%S UTC"
# Same for expiry x=
x=$(grep -m1 -i -A5 '^DKIM-Signature' mail.eml | grep -o -E '\bx=[0-9]+' | head -1 | cut -d= -f2)
date -u -d @"$x" +"%Y-%m-%d %H:%M:%S UTC"
Received/Date header (with time zone) -> UTC:
date -u -d "Mon, 26 Oct 2026 12:30:00 -0700"
date -u -d "Sat, 24 Oct 2026 16:40:12 +0200" +"%Y-%m-%dT%H:%M:%SZ"
UTC -> epoch (to compare with t=):
date -u -d "2026-10-24 14:40:12" +%s
Difference between DKIM signing time and a Received time (seconds):
echo $(( $(date -u -d "Sat, 24 Oct 2026 16:40:12 +0200" +%s) - 1761316800 ))
Python (works everywhere, standard library):
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
print(datetime.fromtimestamp(1700000000, tz=timezone.utc)) # DKIM t=
print(parsedate_to_datetime("Sat, 24 Oct 2026 16:40:12 +0200")
.astimezone(timezone.utc)) # Received/Date -> UTC
Sanity checks: t= should be before (or shortly before) the first Received time. A signing time after delivery, or far in the past or future, is suspicious or points to a wrong clock.
9. Handy commands
# Hashes
md5sum file.zip ; sha256sum file.zip
# DNS
dig +short TXT domain.tld # SPF
dig +short TXT _dmarc.domain.tld # DMARC
dig +short TXT <selector>._domainkey.domain.tld # DKIM key
dig +short MX domain.tld
dig +short -x 203.0.113.25 # reverse DNS
whois 203.0.113.25 # IP owner
# Parse headers with Python
python3 -c "import email,email.policy as p;m=email.message_from_binary_file(open('mail.eml','rb'),policy=p.default);[print(' '.join(str(r).split()),'\n') for r in m.get_all('Received',[])]"
# Attachments
ripmime -i mail.eml -d out/ # or munpack
# S/MIME
openssl smime -verify -in mail.eml -noverify
10. Report template (per task)
- Claim (one sentence, no hedging)
- Evidence (exact header line, line number)
- Source / tool (command or URL, date accessed)
- Limits (what the file cannot prove)
Before submitting: title matches the task, file hash documented, each hop listed with FQDN + IP + protocol, every “outside country X” claim backed by an IP owner lookup.