Email Header Analysis and Sender Tracing
Email headers record the full relay path of a message, from the originating mail client through every server that handled it, and encode authentication outcomes at each hop. Investigators parse these headers to identify the true source IP address, detect spoofing, interpret SPF, DKIM, and DMARC results, and build the legal basis for subscriber record requests.
Last updated:
Every email message carries a header section, invisible in most mail clients, that records the technical journey of the message from its point of origin to the recipient's inbox. Each server that accepts and forwards the message prepends a Received header line, so the complete chain reads from bottom to top, with the oldest entry at the bottom and the most recent at the top. Alongside the relay chain, the header records authentication results: whether the sending server was authorised under SPF, whether the message body was signed under DKIM, and whether the visible From address aligns with those checks under DMARC. For a cyber investigator, this chain is the primary artefact for identifying the originating IP address, detecting spoofed sender addresses, assessing whether authentication mechanisms were bypassed, and building the foundation for a legal request to an internet service provider for subscriber records.
Email spoofing is a common vector in phishing, business email compromise, and impersonation fraud. Attackers set the From header to a trusted domain while routing the message through an unrelated server. Header analysis can expose this mismatch: the Received chain will show an IP address that does not belong to the claimed sending domain, and the authentication results will show SPF fail and DKIM fail. Investigators in India, the United States, the United Kingdom, the European Union, and other jurisdictions increasingly rely on header analysis as the first step before seeking subscriber records from providers, because the header evidence establishes the specific IP and timestamp needed to make the legal request useful.
The technique requires no specialised hardware. Investigators work with the raw message source, which any mail client can export. The key skills are reading the Received chain in the correct order, distinguishing forged display headers from server-added relay headers, interpreting the structured Authentication-Results field, and knowing which headers are legally significant. Familiarity with IP addressing and routing fundamentals and DNS and domain investigation supports the lookup steps that follow initial header parsing.
By the end of this topic you will be able to:
- Read a Received header chain in the correct direction and identify the originating IP address of an email message.
- Distinguish server-added relay headers from client-controlled display headers and explain why the latter can be freely forged.
- Interpret SPF, DKIM, and DMARC results recorded in the Authentication-Results header and explain what each failure indicates about the message.
- Construct an investigative timeline from header timestamps and assess timestamp reliability.
- Describe the legal process for converting a traced IP address into subscriber identity information under Indian, US, UK, and EU frameworks.
- Received header
- A header line prepended by each mail server that accepts a message in transit, recording the server's own identity, the IP or hostname it received the message from, and a timestamp. Reading from bottom to top reveals the relay path.
- SPF (Sender Policy Framework)
- A DNS-based mechanism by which a domain owner publishes the list of IP addresses authorised to send mail for that domain. A receiving server checks whether the envelope sender's domain authorises the connecting IP and records the result as pass, fail, softfail, neutral, or none.
- DKIM (DomainKeys Identified Mail)
- A cryptographic signing mechanism: the sending server signs the message headers and body with a private key, and the receiving server verifies the signature using the public key published in DNS. A valid DKIM signature proves the message was not altered in transit and was signed by the claimed domain.
- DMARC (Domain-based Message Authentication, Reporting, and Conformance)
- A policy layer that requires the domain in the visible From header to align with a domain that passes SPF or DKIM. A DMARC fail means neither SPF nor DKIM produced a passing result aligned with the From domain, which is strong evidence of spoofing.
- Message-ID
- A globally unique identifier assigned to each message by the originating mail server, recorded in the Message-ID header. It is set by the sending MTA and can be forged, but the domain portion often reveals the sending platform or provider.
- Envelope sender (Return-Path)
- The address used at the SMTP protocol level for bounce notifications, recorded in the Return-Path header. It is distinct from the display From address and is what SPF checks. Attackers often spoof the From but not the Return-Path, which creates an inconsistency that header analysis exposes.
Structure of an email header
An email message consists of two parts separated by a blank line: the header section and the body. The header section is a series of name-value pairs, each on its own line (with long values wrapped using whitespace). Many headers are set by the sender's mail client or the originating mail server: From, To, Subject, Date, Message-ID, Reply-To, and Content-Type. These are client-controlled and can be freely set to any value the sender chooses. An attacker composing a phishing email can write any address in the From field.
The headers that matter most for forensic analysis are those added by servers in transit, because the sender's client cannot control what subsequent servers write. Every server that receives the message and passes it along prepends a new Received header at the top of the existing header block. This means the Received headers accumulate in reverse chronological order: the top Received line was added by the server closest to the recipient, and the bottom Received line was added by the first server to accept the message from the sender.
A typical Received line contains: the hostname or IP the message was received from, the hostname of the receiving server, the protocol used (SMTP, ESMTP, ESMTPS), and a timestamp in RFC 2822 format. A minimally informative example reads: Received: from mail.attacker.com (203.0.113.45) by mx.victim.com with ESMTP; Mon, 23 Jun 2025 14:22:01 +0530. The IP in parentheses is the address the receiving server observed the connection coming from. That IP is the forensic data point: it is what the server recorded, not what the sender declared.
| Header | Set by | Can be forged by sender? | Forensic value |
|---|---|---|---|
| From | Sender's mail client | Yes, freely | Identifies claimed sender; confirm against Received chain |
| Return-Path | Sending MTA | Yes, but often inconsistent with From in spoofs | SPF checks this domain; mismatch with From is a spoofing indicator |
| Received | Each relay server | No (server adds its own) | Primary chain of custody; reveals originating IP |
| Message-ID | Originating MTA | Yes | Domain portion may indicate sending platform |
| Authentication-Results | Receiving server | No (server adds it) | Records SPF, DKIM, DMARC pass/fail for that hop |
| X-Originating-IP | Some providers | Sometimes | May record client IP; non-standard and provider-specific |
Tracing the originating IP address
The goal of Received-chain analysis is to identify the IP address from which the message first entered the public mail infrastructure. Starting from the bottom Received line, read the IP address recorded in parentheses after the from clause. This is the address the first public-facing receiving server observed. If the bottom line shows a private IP range (10.x, 172.16-31.x, 192.168.x), the message was submitted from inside a local network and the next line up is the first external hop.
Once the candidate IP is identified, look it up with WHOIS and in a Regional Internet Registry database. ARIN covers North America, RIPE NCC covers Europe and the Middle East, APNIC covers Asia-Pacific, LACNIC covers Latin America, and AFRINIC covers Africa. The lookup returns the organisation that holds the IP block, the allocation date, and contact details. If the IP belongs to a consumer ISP, the next step is a legal request for subscriber records. If it belongs to a cloud provider, VPN service, or Tor exit node, the interpretation changes: the IP identifies the service, not the individual.
Check the geolocation of the IP using a service such as MaxMind GeoLite2 or ipinfo.io. Geolocation is approximate, not reliable to city level, but country-level accuracy is generally high and can immediately flag whether the originating country is inconsistent with the claimed sender. A message claiming to be from a bank headquartered in one country but originating from an IP geolocated to a different continent is a strong indicator of fraud.
Interpreting SPF, DKIM, and DMARC results
Modern mail systems record the outcome of authentication checks in the Authentication-Results header, added by the receiving server at each hop that performs the checks. A single Authentication-Results field can contain results for SPF, DKIM, and DMARC. The field is structured: the reporting server's name appears first, followed by each mechanism and its result.
SPF checks whether the IP address that connected to the receiving server is listed in the DNS TXT record of the domain in the Return-Path. Possible results: pass (authorised), fail (explicitly not authorised), softfail (the domain discourages but does not prohibit), neutral (the domain makes no claim), and none (no SPF record found). An SPF fail means the sending server was not authorised to send for the Return-Path domain. In a spoofed phishing email, the attacker typically sets the From to a legitimate domain but routes the message through their own server, producing SPF fail.
DKIM provides a cryptographic signature over specified header fields and the message body. The receiving server retrieves the public key from DNS and verifies the signature. A DKIM pass means the message was signed by the claimed domain and was not altered in transit. A DKIM fail means the signature did not verify, which could indicate tampering, key rotation that broke existing messages, or a forged DKIM-Signature header. A missing DKIM signature is recorded as none and is not itself suspicious, since many smaller mail servers do not implement DKIM.
DMARC combines both mechanisms with an alignment requirement: it requires that either the SPF-checked domain or the DKIM-signed domain aligns with the domain in the visible From header. If an attacker spoofs a From address at bank.com but routes through their own server, SPF checks their server's domain, not bank.com, so SPF alignment fails. If they have no DKIM key for bank.com, DKIM alignment fails too. DMARC therefore fails. The Authentication-Results header records dmarc=fail, along with the reason.
| Mechanism | What it checks | Typical fail indicator | Investigative significance |
|---|---|---|---|
| SPF | Is the sending IP authorised by the Return-Path domain? | spf=fail or spf=softfail | Sending server not authorised; likely not a legitimate sender for claimed domain |
| DKIM | Does the cryptographic signature over headers and body verify? | dkim=fail or dkim=none | fail = message altered or key mismatch; none = no signing, not inherently suspicious |
| DMARC | Does SPF or DKIM align with the visible From domain? | dmarc=fail | Strong indicator of From address spoofing; attacker does not control the claimed domain's infrastructure |
Identifying spoofing and display-name attacks
Spoofing covers several distinct techniques that header analysis can differentiate. In a direct domain spoof, the attacker sets the From header to an address at the exact target domain (from: admin@targetbank.com) while routing the message through their own server. This produces SPF fail and DMARC fail and is the simplest form to detect. If the target domain has published a strict DMARC policy (p=reject), compliant receiving servers will reject the message entirely; the investigator may encounter it only in mail server logs.
A lookalike domain spoof uses a domain registered to resemble the target: targetb4nk.com, target-bank.com, or targetbank.co. The attacker controls this domain and can configure SPF and DKIM to pass. Authentication checks pass legitimately; the attack succeeds by visual deception in the display name or domain. Investigators should check the exact From domain against the expected domain using string comparison, not visual inspection. Run WHOIS on the From domain: registration date, registrar, and registrant contact are all investigatively useful.
A display-name attack leaves the actual email address at a different domain but sets the display name to a trusted name: the From field displays as Finance Director <accounts@random-provider.com>. Mail clients that show only the display name, not the actual address, make this effective. The full raw From header reveals the real address. Investigators must always examine the raw header, not the rendered mail client view.
Using tools to parse and analyse headers
Manual parsing of a long Received chain is error-prone. Several free tools automate the process. Google Admin Toolbox Message Header Analyser parses the Received chain and renders each hop with timestamp deltas. MXToolbox Email Header Analyzer extracts the originating IP, checks it against common blocklists, and displays authentication results in a readable format. For investigators who need to process multiple messages, Python's email standard library can parse raw message files (eml format) programmatically, and the imaplib module can retrieve messages directly from a mail server.
After extracting the originating IP, look it up in threat intelligence sources. VirusTotal aggregates data from multiple security vendors and shows whether the IP has been associated with malicious activity. AbuseIPDB records reported abuse from that IP. Shodan shows open ports and services running at that IP, which can indicate whether it belongs to a mail server, a residential connection, a proxy, or a VPN endpoint. A VPN or proxy IP does not end the investigation: many VPN providers retain connection logs and will respond to valid legal process.
For domain lookups, use dig or nslookup to query the SPF record directly: dig TXT targetdomain.com. The SPF record begins with v=spf1 and lists the mechanisms. Querying the DMARC record: dig TXT _dmarc.targetdomain.com. The DMARC record includes the policy (p=none, p=quarantine, or p=reject) and the reporting addresses. A domain with p=none has not enabled DMARC enforcement; attackers can spoof it with no automatic rejection. A domain with p=reject has the highest protection: receiving servers compliant with DMARC will reject spoofed messages before they reach the inbox.
Legal process for subscriber record requests
Identifying the originating IP address is not the end of the investigation: the IP belongs to a network block owned by a provider, and the provider holds the subscriber records that map the IP to a customer at a specific time. Obtaining those records requires legal process, and the process varies by jurisdiction. The critical information for the request is the IP address, the precise timestamp including time zone (UTC preferred), and the protocol (SMTP, typically on port 25 or 587).
In India, investigators operate under the Information Technology Act 2000 for cyber offences and under the Bharatiya Nagarik Suraksha Sanhita 2023 (which replaced the Code of Criminal Procedure) for procedural steps including production orders. Section 69 of the IT Act empowers authorised agencies to direct an intermediary to provide information. Section 91 of the Bharatiya Nagarik Suraksha Sanhita 2023 covers summons for documents and records. The Bharatiya Sakshya Adhiniyam 2023 (which replaced the Indian Evidence Act 1872) governs admissibility of electronic records, including the certificate under section 63 that authenticates electronic evidence for court proceedings.
In the United States, the Stored Communications Act (18 U.S.C. 2701 et seq.) governs access to stored electronic communications and subscriber records held by providers. A subpoena (18 U.S.C. 2703(c)(2)) can compel disclosure of basic subscriber information. A court order under 2703(d) compels records of account activity. A search warrant under 2703(a) is required for content. In the United Kingdom, the Investigatory Powers Act 2016 governs the interception of communications and acquisition of communications data; production orders for subscriber records are issued under the Police and Criminal Evidence Act 1984 or the Proceeds of Crime Act 2002 depending on the offence. In the European Union, the e-Evidence Regulation (Regulation (EU) 2023/1543) establishes European Production Orders for electronic evidence held by providers in any member state.
An email has three Received headers. In what order should an investigator read them to trace the message path from sender to recipient?
Key Takeaways
- Received headers are added by each relay server and cannot be inserted by the original sender; reading them bottom to top reveals the relay path and the originating IP address at the bottom entry.
- Display headers (From, Subject, Reply-To) are client-controlled and freely forgeable; the Received chain and Authentication-Results are server-controlled and provide the reliable forensic record.
- SPF checks whether the sending IP is authorised for the Return-Path domain; DKIM verifies a cryptographic signature over the message; DMARC requires alignment between those results and the visible From domain. All three failing together is a strong indicator of spoofing.
- Lookalike domain attacks pass all three authentication checks because the attacker controls the fraudulent domain; detection depends on careful string comparison of the From domain, not on authentication results alone.
- Converting a traced IP to a subscriber identity requires legal process directed at the IP block owner: in India under the IT Act 2000 and Bharatiya Nagarik Suraksha Sanhita 2023; in the US under 18 U.S.C. 2703; in the UK under the Investigatory Powers Act 2016; and in the EU under the e-Evidence Regulation 2023/1543. Preservation requests should be sent immediately to prevent log expiry.
Which email header field shows the true originating IP address?
What does an SPF fail result in an email header mean?
Can email headers be forged by a sender?
What legal mechanism is used to obtain subscriber records for a traced IP address?
What is DMARC and how does it help an investigator?
Test yourself on Cyber Forensics with free, timed mocks.
Practice Cyber Forensics questionsSpotted an error in this page? Report a correction or read our editorial standards.