Why Email Header Analysis Matters
Email header analysis is a critical skill for security professionals, IT administrators, and anyone investigating suspicious emails. Headers contain forensic information about how a message was routed, where it originated, whether it passed authentication checks, and whether it was modified in transit. However, email headers are notoriously difficult to read—they're often hidden by email clients, presented in a confusing format, and contain technical jargon that obscures their meaning.
The difference between a security professional who can quickly identify a phishing email from raw headers and someone who's stumped by them comes down to having the right tools and understanding the techniques for extracting, parsing, and interpreting header data. This guide covers both the manual techniques security professionals use and the specialized tools that automate header analysis.
Manually Extracting Email Headers
Email Client Methods
The first step in header analysis is getting access to the full headers. Different email clients store headers in different locations:
Gmail/Google Workspace
- Open the email
- Click the three-dot menu (More options)
- Select "Show original"
- Copy the entire content including headers and body
- Paste into a text editor or analysis tool
Outlook/Microsoft 365
- Open the email
- Click "File" > "Properties" (Outlook desktop)
- Look for "Internet Headers" field
- Copy and paste full headers
Apple Mail
- Open the email
- Choose View menu > Message > Show All Headers
- Copy headers from the displayed text
Thunderbird
- Open the email
- Click View > Message Body As > Plain Text
- Scroll to see full headers
Exporting Raw Email Files
For more complete forensic analysis, export the email in its native format:
EML Format: Stores complete email including headers, body, and attachments
- Gmail: Use Google Takeout to export emails
- Outlook: Save as file, then rename .msg to .eml for text parsing
- Thunderbird: Right-click email, select "Save As"
PST/OST Format: Outlook's proprietary format
- Contains multiple emails and folder structure
- Requires Outlook or specialized PST readers to parse
- Can be analyzed with tools like RecoveryTools PST Viewer
MBOX Format: Standard format used by many email systems
- Contains one or more emails in text format
- Each email separated by "From " line
- Can be opened with text editors
Manual Header Parsing Technique
For critical investigations, manually reading headers teaches you to spot patterns:
- Scroll to the bottom of the headers (the oldest entries)
- Read Received headers upward (reverse chronological order of hops)
- Extract IP addresses from each Received header
- Note timestamps and compare for consistency
- Look for suspicious patterns:
- Unexpected mail server names
- Unusual IP addresses
- Time gaps between hops
- DNS mismatches
- Check authentication results: SPF, DKIM, DMARC, Authentication-Results
- Compare properties: Sender domains, return paths, envelope senders
Specialized Email Header Analysis Tools
Online Header Analyzers
Email Header Analyzer (Inventive HQ)
A free, specialized tool that parses email headers and provides:
- Automatic SPF/DKIM/DMARC result interpretation
- IP geolocation with map visualization
- Mail server routing diagram
- Authentication result details
- Red flag highlighting for suspicious patterns
- Clear visual presentation of complex data
Simply paste raw headers and instantly get a comprehensive analysis with visual representations.
MXToolbox Email Header Analysis
MXToolbox offers several header analysis features:
- SPF record validation and explanation
- Received header parsing
- Authentication result interpretation
- Blacklist checking
- Simple, web-based interface
- No account required
Google Admin Toolbox - Messageheader
Google's free tool specifically for analyzing Gmail and Google Workspace headers:
- Visualizes mail flow path
- Shows timestamps and delays
- Highlights suspicious patterns
- Specifically designed for Google infrastructure
Phishtool
Browser extension and online service that helps analyze suspected phishing emails:
- Integrates with Gmail
- Extracts headers automatically
- Analyzes URLs and attachments
- Provides phishing indicators
- Links to threat intelligence databases
Enterprise Email Security Solutions
Proofpoint: Advanced threat detection with header analysis
- Scans headers for suspicious patterns
- Integrates with email systems
- Provides forensic details on compromised accounts
- Large-scale analysis of email traffic
Mimecast: Email security platform with header-based threat detection
- Advanced analytics on email flows
- Threat intelligence integration
- User awareness training
- Integrates with major email providers
Cisco Ironport: Email gateway with deep header analysis
- Gateway-level header inspection
- Authentication enforcement
- Threat reputation lookups
- Large-scale deployments
Manual Techniques for Different Investigation Types
Investigation: Phishing Email Detection
Steps:
- Extract headers from the suspected phishing email
- Check Authentication-Results for SPF/DKIM/DMARC status:
- All failures = strong phishing indicator
- Passes for unexpected domain = domain spoofing
- Alignment fails = impersonation
- Look at Received headers for suspicious mail servers
- Extract URLs from email body and analyze
- Check Received-SPF header for domain matching
- Review Return-Path vs. From: header mismatch
- Check X-Originating-IP for unexpected location
Red Flags:
- SPF fail, DKIM fail, DMARC fail
- X-Originating-IP in unexpected country
- Mail server domains don't match claimed organization
- Timestamp inconsistencies
- URLs showing different domain than email claims
Investigation: Business Email Compromise
Steps:
- Compare current email headers to baseline of legitimate emails from sender
- Look for new/unusual X-Originating-IP addresses
- Check for unusual DKIM signatures if account compromised
- Look at Received timestamps - does timing match normal work hours?
- Check timezone consistency in headers vs. employee location
- Review forwarding rules added to mailbox
- Check for unusual Authentication-Results patterns
Red Flags:
- New IP addresses not in baseline
- Emails sent outside normal work hours
- Different timezone than employee location
- New Mail-From addresses
- Changed DKIM selectors
Investigation: Account Compromise
Steps:
- Extract headers from all recent emails from the account
- Create baseline: Document normal Received headers, IPs, authentication
- Compare recent emails to baseline
- Look for new X-Originating-IP addresses
- Check for new User-Agent entries (different email clients)
- Review Received-From patterns for anomalies
- Check for login location changes in mailbox logs
- Analyze SPF alignment changes
Red Flags:
- New IP addresses sending emails
- Email clients from unexpected platforms
- Unusual Received header chains
- Modified forwarding rules
- New application authorizations
Automated Analysis Techniques
Email Log Analysis
For organizations with email logs, automated analysis can detect patterns:
Create alerts for:
- Emails failing all authentication checks
- Emails from unexpected geographic regions
- Sudden spike in emails from specific accounts
- Authentication failures followed by successful sends
- Emails with modified Return-Path domains
- Unusual Received header patterns
Tools for log analysis:
- Splunk: Creates custom dashboards and alerts from email logs
- ELK Stack (Elasticsearch): Free alternative for log analysis
- Sumo Logic: Cloud-based log management
- Cloud provider tools: Google Cloud Logging, Azure Monitor
Regex Patterns for Header Parsing
For developers and advanced analysts, regular expressions can extract specific information:
Extract all IP addresses from Received headers:
(?:[0-9]{1,3}\.){3}[0-9]{1,3}
Extract domain names from Received headers:
(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}
Extract Authentication-Results status:
Authentication-Results:.*?(spf|dkim|dmarc)=(pass|fail|softfail|neutral|none|temperror|permerror)
These patterns can be used with tools like grep, sed, or in custom Python/PowerShell scripts.
Python for Header Analysis
Security professionals often write Python scripts for custom analysis:
import email
import re
from email.parser import Parser
# Parse email file
with open('email.eml', 'r') as f:
msg = email.message_from_file(f)
# Extract headers
headers = msg.items()
for header, value in headers:
if header == 'Received':
print(f"Received: {value}")
elif header == 'Authentication-Results':
print(f"Auth-Results: {value}")
elif header == 'X-Originating-IP':
print(f"Originating IP: {value}")
# Extract IP addresses
received_headers = msg.get_all('Received', [])
ip_pattern = r'\[?(?:[0-9]{1,3}\.){3}[0-9]{1,3}\]?'
for received in received_headers:
ips = re.findall(ip_pattern, received)
for ip in ips:
print(f"Found IP: {ip}")
Scripts like this can:
- Parse multiple emails at once
- Extract specific headers automatically
- Format results for further analysis
- Generate statistics across many emails
- Integrate with WHOIS and geolocation APIs
Building a Header Analysis Workflow
For Security Professionals
Quick Analysis (2-5 minutes):
- Use Email Header Analyzer tool - paste headers
- Look at authentication results
- Check IP geolocation
- Scan for red flags in the tool's output
- Make pass/fail decision
Deep Dive Analysis (15-30 minutes):
- Extract raw headers to text file
- Manually parse Received headers
- Create IP list and geolocate each
- Do WHOIS lookups on suspicious IPs
- Check SPF records for sending domain
- Review DKIM records and selectors
- Analyze complete routing path
- Compare to baseline if account-related
- Document findings
For IT Administrators
Email System Monitoring:
- Configure email server logging (enable verbose headers)
- Use email security appliance dashboard (Proofpoint, Mimecast, etc.)
- Set up alerts for authentication failures
- Create reports on DMARC alignment
- Monitor for new/suspicious mail routes
- Alert on emails from geographic anomalies
- Review unusual SPF/DKIM changes
For Incident Response Teams
Systematic Investigation:
- Collect all emails from incident
- Export in EML format
- Parse headers automatically with script
- Create timeline visualization
- Map IP addresses to locations
- Identify email chains and forwarding
- Preserve evidence in proper format
- Document findings with screenshots
- Present timeline to stakeholders
Conclusion
Effective email header analysis requires a combination of tools and techniques. For quick analysis, free online tools like Email Header Analyzer provide instant insights. For deeper investigations, manual header parsing combined with WHOIS lookups, geolocation tools, and DNS analysis reveals detailed forensic information. For large-scale monitoring, automated log analysis and alert systems detect suspicious patterns across thousands of emails.
The most effective security organizations combine all these approaches: they empower individual analysts with easy-to-use tools for quick decisions, invest in specialized tools for deep investigations, and deploy automated systems for continuous monitoring. By mastering both manual header analysis and modern analytical tools, security professionals can quickly identify phishing attempts, detect account compromises, and investigate email-based security incidents before they cause significant damage.


