---
title: "Send the headers every message needs · Agent Wranglers"
url: https://agentwranglers.se/playbook/email/message-basics/required-headers
updated: 2026-10-20
licence: "All rights reserved"
---

# Send the headers every message needs

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Message basics](https://agentwranglers.se/playbook/email/message-basics)
- Rule: Give every message exactly one `From`, `To`, `Subject`, `Date` and `Message-ID`, in the format RFC 5322 sets out.
- How: Let your mail library build the headers instead of writing them by hand. `From` names one mailbox on a domain you control. `Date` uses the RFC 5322 format with a time zone. `Message-ID` is globally unique, such as a random value at your own domain. RFC 5322 requires only `From` and `Date`. Gmail's sender rules also ask for a valid `Message-ID` and single copies of `From`, `To`, `Subject` and `Date`.
- Check: Open a test message with "show original". `From`, `Date`, `Message-ID`, `Subject` and `To` each appear exactly once, and the `Message-ID` ends in your own domain.

Example:

```text
From: Example Shop <orders@example.com>
To: Ada Lovelace <ada@example.org>
Subject: Your order 1042 has shipped
Date: Tue, 20 Oct 2026 09:30:00 +0200
Message-ID: <7f3c9a2e-4b1d-4e8a-9c0f-1a2b3c4d5e6f@example.com>
```

```python
from email.message import EmailMessage
from email.utils import formatdate, make_msgid

msg = EmailMessage()
msg["From"] = "Example Shop <orders@example.com>"
msg["To"] = "ada@example.org"
msg["Subject"] = "Your order 1042 has shipped"
msg["Date"] = formatdate(localtime=True)
msg["Message-ID"] = make_msgid(domain="example.com")
```

```js
import { randomUUID } from 'node:crypto';

await transporter.sendMail({
  from: 'Example Shop <orders@example.com>',
  to: 'ada@example.org',
  subject: 'Your order 1042 has shipped',
  date: new Date(),
  messageId: `<${randomUUID()}@example.com>`,
});
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers email playbook: https://agentwranglers.se/playbook/email/message-basics/required-headers`.

- Next: [Point replies to a mailbox someone reads](https://agentwranglers.se/playbook/email/message-basics/reply-to)
- [Message basics](https://agentwranglers.se/playbook/email/message-basics)
