Time looks like the least interesting part of an email, yet a surprising number of delivery problems come from it. A message dated three years in the future is a classic spam signal. A server whose clock has drifted by ten minutes produces DKIM signatures that look expired or created in the future to the receiver, and TLS handshakes that fail because certificates appear to be invalid. A script that sets the Date header in the wrong format makes messages appear at the top of the inbox for ever, or at the bottom. This guide explains how the Date header works and what the standards require, which systems depend on accurate clocks, how filters and clients react to bad dates, how to diagnose problems from message headers and how to fix them with time synchronisation and sending-code changes. It relates to reading headers and debugging delivery with headers.
What the Date header is
RFC 5322 requires every message to have an origination date header, which records when the sender finished composing the message. The format is fixed:
Date: Tue, 06 May 2025 14:32:08 +0530
Received: from mail.example.com (mail.example.com [203.0.113.10])
by mx.example.net with ESMTPS id abc123
for <[email protected]>; Tue, 6 May 2025 09:02:09 +0000The Date header uses the sender's local time with a numeric offset from UTC; here +0530 means five hours and thirty minutes ahead of UTC. The Received lines are added by each server that handles the message and use that server's clock. Comparing them reveals delays and clock disagreements. In the example, 14:32:08 at +0530 equals 09:02:08 UTC, and the receiving server stamped 09:02:09: consistent. A big gap would be suspicious.
What can go wrong
| Problem | Cause | Effect |
|---|---|---|
| Date in the future | Wrong system clock, wrong time zone setting, bug in the sending code | Spam filters penalise; clients sort the message at the top of the list or show odd times |
| Date far in the past | Template or script reuses a fixed date; a message resent from a stored copy keeps the original date | Some filters distrust old dates; recipients are confused |
| Missing Date header | Custom script writes raw SMTP without headers | Some servers add one; others reject or score the message down |
| Invalid format | Locale-specific month names, missing day of week mismatch, wrong zone abbreviations | Parsing errors; clients may show epoch time (1970) or no date |
| Wrong time zone offset | Server in one zone but labelled with another | Messages appear hours early or late |
| Clock drift on the sending server | NTP not running; virtual machine paused; battery-backed clock failure | DKIM, TLS and token checks fail intermittently |
| Daylight saving errors | Local time with a stale offset after a change | Off-by-one-hour times twice a year |
| Date header not matching Received timeline | Message injected with an old Date; mailing list resend | Often harmless, but a pattern used by spammers, so filters take note |
Systems that depend on accurate clocks
- DKIM. Signatures may include a timestamp (
t=) and an expiry (x=). A receiver rejects or distrusts a signature that has expired, or whose timestamp lies in the future beyond a small tolerance. A fast or slow clock on the signing server therefore breaks authentication. See DKIM failures and DKIM key rotation. - TLS. Certificates have start and end dates. A server whose clock is behind sees a valid certificate as "not yet valid"; one that is ahead sees it as expired. Symptoms include sudden TLS errors that clear after correcting the time. See SMTP certificates and certificate errors.
- Time-limited tokens. Signed URLs, webhook timestamps and one-time passwords include timestamps; drift of a few minutes makes them fail. See webhook signature verification and OTP email.
- SPF, DMARC and DNS do not use message time, but DNS caching and TTLs interact with changes you make.
- Greylisting and rate limits. These use the receiver's clock, which is usually accurate.
- Logs and tracing. If servers disagree about the time, you cannot correlate events across systems. See tracing messages.
How filters and clients treat dates
Spam filters compare the Date header with the time they received the message. A message that claims to be from a few days earlier can be a legitimate delay; one from the future or from many years ago is suspicious. Many rule sets assign a small penalty for these cases, which can tip a borderline message into spam. Mail clients sort by the date they received or by the Date header, depending on settings, so a bad value can place a message out of order. Notification systems may show "in 3 hours" for a future date. None of this is dramatic on its own, but it adds to the overall score, and for new or low-reputation senders every point counts. See how content filters work.
Diagnosing a date problem
- Open the original message source of a bad example. Find the Date header and each Received line.
- Convert all times to UTC and compare. The first Received line (the oldest, at the bottom) should be close to the Date header. Large differences suggest a wrong Date, a delayed queue or a clock problem.
- Check the sending server's clock with the date command and compare with a trusted time source. Check whether the NTP service is running and synchronised.
- Check the application: does it set Date itself, or leave it to the mail library or server? Does it reuse a stored date when resending?
- Check the time zone configuration of the server, container and application. Containers often default to UTC while the application assumes local time.
- Check authentication results. Look at the Authentication-Results header for DKIM failures with messages about expiry or timestamps.
- Check TLS errors in logs for "certificate not yet valid" or "expired" messages that coincide with clock drift.
# Linux: check clock and synchronisation
timedatectl status
chronyc tracking # or: ntpq -p
date -u
# Compare with a reference
curl -sI https://www.example.org | grep -i '^date:' Fixing it
| Cause | Fix |
|---|---|
| No time synchronisation | Install and enable chrony or ntpd (or the platform's time service); use several reliable sources; monitor offset |
| Virtual machines drifting after pause or migration | Enable host time sync or guest agent sync, and NTP inside the guest |
| Container using the wrong zone | Set the container time zone explicitly and keep application times in UTC |
| Application builds Date by hand | Remove custom code; use the library's function that formats RFC 5322 dates, or let the MTA add the header |
| Resending stored messages with old Date | Regenerate the Date header on resend, or send a new message |
| Locale problems in date formatting | Use a library that formats in English month and day names regardless of the locale |
| Daylight saving errors | Compute offsets from a time zone database, or use UTC (+0000) |
| DKIM expiry too short | Use an expiry long enough for delays, or omit x= unless you need it |
# Correct Date header generation
Python: from email.utils import formatdate; formatdate(localtime=False, usegmt=False)
Node.js: new Date().toUTCString() # then adjust to the RFC 5322 style if the library requires it
PHP: date(DATE_RFC2822)
Java: DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now())Best practices
- Keep all servers on UTC and let clients display local time.
- Run time synchronisation everywhere, including build agents, containers and any server that signs mail or issues tokens.
- Alert when clock offset exceeds a small threshold, such as a second or a few seconds.
- Let the mail library or the MTA add the Date header unless you have a strong reason to do otherwise.
- Test messages by sending to a few mailboxes and verifying the displayed time against reality.
- Include a time check in your incident runbook for sudden authentication or TLS failures. See incident runbook.
- Document the time zone and the NTP sources in your infrastructure notes.
A correct clock is invisible when it works and baffling when it does not. A few minutes of setup, monitoring and good library use protects authentication, encryption and reputation from a class of problems that are easy to avoid.
Debug your headers Check authentication results for a sample message.
References and further reading
Frequently asked questions
Why does my email show the wrong time?
The Date header may carry a wrong time or offset, often because of a server clock, time zone or code error. Check the message source.
Do wrong dates cause spam filtering?
They can add a penalty, especially dates in the future or far in the past, and can tip borderline messages into spam.
How does clock drift affect DKIM?
Signatures with timestamps or expiry may be treated as expired or future-dated if the signing server's clock is wrong.
Should I set the Date header myself?
Usually not. Let the mail library or MTA generate it in the correct RFC 5322 format.
How do I keep server clocks accurate?
Run NTP or chrony on every server and container host, monitor the offset and alert on drift.