hermes - ✅(Solved) Fix [Bug]: Outbound Hermes emails missing Date header — bounced by mail filter [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#15160Fetched 2026-04-25 06:24:07
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×5cross-referenced ×2

Error Message

Additional Logs / Traceback (optional)

Root Cause

Outbound Hermes emails sent via the email gateway and via send_message_tool._send_email are accepted by SMTP but bounced downstream with "Undeliverable mail, invalid header section — missing required header field: Date". The send looks successful in Hermes because SMTP's 250 OK arrives before the receiving filter rejects the message.

Fix Action

Fixed

PR fix notes

PR #15164: fix(email): add required Date header to outbound mail

Description (problem / solution / changelog)

What does this PR do?

Outbound Hermes emails could appear to send successfully via SMTP but never reach the recipient. The receiving mail filter later bounced them with:

Undeliverable mail, invalid header section — missing required header field: "Date"

The three outbound code paths in the email gateway and send_message_tool built MIMEMultipart / MIMEText messages without ever setting a Date header. SMTP accepted the message locally (so the send looked successful), but the downstream filter rejected it during validation. RFC 5322 requires a Date header.

This PR sets msg["Date"] = email.utils.formatdate(localtime=True) in the three affected outbound paths. Message-ID was already being set, so it is not touched.

Related Issue

Fixes #15160

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/email.py: set msg["Date"] in both EmailAdapter._send_email paths (text reply and attachment send). Added from email.utils import formatdate.
  • tools/send_message_tool.py: set msg["Date"] in the standalone _send_email function.
  • tests/gateway/test_email.py: added assertIn("Date", send_call) to the three affected send tests.

How to Test

  1. Configure the email platform (EMAIL_ADDRESS, EMAIL_PASSWORD, EMAIL_SMTP_HOST, EMAIL_IMAP_HOST) and run the gateway.
  2. Trigger an outbound reply from Hermes — confirm the outgoing message has a Date header and is delivered (no postmaster bounce).
  3. Trigger an outbound send with an attachment (e.g. a generated voice message) — confirm the same.
  4. Run the targeted test suite: uv run pytest tests/gateway/test_email.py -q — 54 passed locally.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Linux (Linux, kernel 5.14.0), Python 3.13.5

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A (stdlib email.utils only)
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

N/A — the bug evidence (postmaster bounce) is attached to the linked issue #15160.

Changed files

  • gateway/platforms/email.py (modified, +3/-0)
  • tests/gateway/test_email.py (modified, +7/-0)
  • tools/send_message_tool.py (modified, +2/-0)

PR #15230: fix(email): add Date header to send_message_tool._send_email (closes #15160)

Description (problem / solution / changelog)

Closes #15160

Summary

Adds the required RFC 5322 Date header to the _send_email tool path in tools/send_message_tool.py.

Issue #15160 reported that outbound Hermes emails are bounced by mail filters with 'Missing required header field: Date'. The issue noted two affected code paths:

  1. gateway/platforms/email.py - fixed by PR #15207
  2. tools/send_message_tool._send_email - was NOT covered by PR #15207

The send_message tool uses _send_email for cross-channel messaging (terminal, file ops, web, code execution, etc.), so outbound emails from these tools were still missing the Date header after PR #15207.

Fix

  • Import formatdate from email.utils at module level
  • Add msg['Date'] = formatdate(localtime=True) after subject header in _send_email

This mirrors the fix applied to gateway/platforms/email.py in PR #15207.

Testing

The existing test in tests/gateway/test_email.py covers the gateway path.

Changed files

  • tools/send_message_tool.py (modified, +3/-1)

Code Example

--- hermes dump ---
version:          0.11.0 (2026.4.23) [(unknown)]
os:               Linux 5.14.0-570.58.1.el9_6.x86_64 x86_64
python:           3.13.5
openai_sdk:       2.32.0
profile:          default
hermes_home:      ~/.
model:            gpt-5.4
provider:         openai-codex
terminal:         local

api_keys:
  openrouter           not set
  openai               not set
  anthropic            not set
  anthropic_token      not set
  nous                 not set
  glm/zai              not set
  zai                  not set
  kimi                 not set
  minimax              not set
  deepseek             not set
  dashscope            not set
  huggingface          set
  nvidia               not set
  ai_gateway           not set
  opencode_zen         not set
  opencode_go          not set
  kilocode             not set
  firecrawl            not set
  tavily               not set
  browserbase          not set
  fal                  not set
  elevenlabs           not set
  github               set

features:
  toolsets:           hermes-cli
  mcp_servers:        0
  memory_provider:    built-in
  gateway:            running (docker (foreground), pid 1)
  platforms:          email
  cron_jobs:          0 active / 0 total
  skills:             92

config_overrides:
  display.streaming: True
--- end dump ---

---

The message WAS NOT relayed to:
  <xxx@googlemail.com>:
   554 5.6.0 Bounce, id=853245-18 - BAD HEADER

This nondelivery report was generated by the program amavisd-new at host
xxx. Our internal reference code for your message is
853245-18/3yKE3K_Kg1W7

INVALID HEADER

  Missing required header field: "Date"

Return-Path: <xxx@xxx>
From: xxx@xxx
Subject: Your voice message
RAW_BUFFERClick to expand / collapse

Bug Description

Outbound Hermes emails sent via the email gateway and via send_message_tool._send_email are accepted by SMTP but bounced downstream with "Undeliverable mail, invalid header section — missing required header field: Date". The send looks successful in Hermes because SMTP's 250 OK arrives before the receiving filter rejects the message.

Steps to Reproduce

  1. Configure the email platform (EMAIL_ADDRESS, EMAIL_PASSWORD, EMAIL_SMTP_HOST, EMAIL_IMAP_HOST).
  2. Trigger an outbound reply from Hermes (or send an attachment).
  3. Check the Hermes inbox — a postmaster bounce arrives shortly after with "missing required header field: Date".

Expected Behavior

Outbound messages include RFC 5322's required Date header and are delivered to the recipient.

Actual Behavior

SMTP reports success, but the message is later bounced by the receiving mail filter because the Date header is absent.

Affected Component

Tools (terminal, file ops, web, code execution, etc.), Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

No response

Debug Report

--- hermes dump ---
version:          0.11.0 (2026.4.23) [(unknown)]
os:               Linux 5.14.0-570.58.1.el9_6.x86_64 x86_64
python:           3.13.5
openai_sdk:       2.32.0
profile:          default
hermes_home:      ~/.
model:            gpt-5.4
provider:         openai-codex
terminal:         local

api_keys:
  openrouter           not set
  openai               not set
  anthropic            not set
  anthropic_token      not set
  nous                 not set
  glm/zai              not set
  zai                  not set
  kimi                 not set
  minimax              not set
  deepseek             not set
  dashscope            not set
  huggingface          set
  nvidia               not set
  ai_gateway           not set
  opencode_zen         not set
  opencode_go          not set
  kilocode             not set
  firecrawl            not set
  tavily               not set
  browserbase          not set
  fal                  not set
  elevenlabs           not set
  github               set

features:
  toolsets:           hermes-cli
  mcp_servers:        0
  memory_provider:    built-in
  gateway:            running (docker (foreground), pid 1)
  platforms:          email
  cron_jobs:          0 active / 0 total
  skills:             92

config_overrides:
  display.streaming: True
--- end dump ---

Operating System

Linux 66679abce06b 5.14.0-570.58.1.el9_6.x86_64

Python Version

3.13.5

Hermes Version

0.11.0

Additional Logs / Traceback (optional)

The message WAS NOT relayed to:
  <[email protected]>:
   554 5.6.0 Bounce, id=853245-18 - BAD HEADER

This nondelivery report was generated by the program amavisd-new at host
xxx. Our internal reference code for your message is
853245-18/3yKE3K_Kg1W7

INVALID HEADER

  Missing required header field: "Date"

Return-Path: <xxx@xxx>
From: xxx@xxx
Subject: Your voice message

Root Cause Analysis (optional)

gateway/platforms/email.py (_send_email, reply and attachment paths) and tools/send_message_tool.py (_send_email) construct MIMEMultipart / MIMEText messages without ever setting a Date header. RFC 5322 requires it; the receiving filter enforces it. Message-ID is already being set, so only Date needs to be added.

Proposed Fix (optional)

Set msg["Date"] = email.utils.formatdate(localtime=True) at message construction in all three outbound paths. Regression tests added in tests/gateway/test_email.py assert Date is present. PR ready.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

Set the "Date" header in the email message construction using email.utils.formatdate(localtime=True) to fix the issue.

Guidance

  • The root cause is the missing "Date" header in the email messages sent by Hermes, which is required by RFC 5322.
  • To fix this, add msg["Date"] = email.utils.formatdate(localtime=True) in the message construction code in gateway/platforms/email.py and tools/send_message_tool.py.
  • Verify the fix by checking the email headers in the sent messages and ensuring that the "Date" header is present.
  • Run the regression tests added in tests/gateway/test_email.py to confirm that the fix works as expected.

Example

import email.utils
from email.mime.text import MIMEText

# ...

msg = MIMEText("Hello, world!")
msg["Date"] = email.utils.formatdate(localtime=True)

Notes

This fix assumes that the email module is available and that the formatdate function is used correctly. Additionally, this fix only addresses the specific issue of the missing "Date" header and may not fix other potential issues with the email sending code.

Recommendation

Apply the proposed fix by setting the "Date" header in the email message construction, as it is a straightforward and standards-compliant solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: Outbound Hermes emails missing Date header — bounced by mail filter [2 pull requests, 1 participants]