Skip to content

[Bug]: Herd Mailserver crashes with RangeError: Invalid time value on malformed/missing Date header #1695

@andyunleashed

Description

@andyunleashed

Platform

macOS

Operating system version

Tahoe 26.3.1

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.28.0

PHP Version

PHP 8.4

Bug description

When sending an email via the Herd Mail SMTP server (port 2525) using a raw socket connection (e.g., basic PHP fsockopen), the Mailserver process crashes if the Date header is missing or malformed.

Steps to reproduce

Steps to Reproduce

  1. Start the Herd Mail service.
  2. Send a raw SMTP DATA command payload that does not include a Date: header.
  3. The Node.js process for the mailserver will crash immediately with the above error.

Expected Behavior

  • Automatically inject a valid Date header if missing
  • Fail gracefully with an SMTP error code rather than an uncaught Node.js exception that kills the service.

To solve it locally I popped in a date header, e.g: 'Date' => date('r'),

Log output

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^
RangeError: Invalid time value
    at Date.toISOString (<anonymous>)
    at ensureMessageTypes (/snapshot/herd-mailserver/lib/ensureMessageTypes.js)
    at /snapshot/herd-mailserver/index.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions