JMAP Email/set generates Message-ID using local node hostname

Issue Description

When a message is created through JMAP Email/set without a client-supplied
Message-ID, Stalwart generates the Message-ID using the operating
system/container hostname.

I observed this while sending a message from the Mailtemi client on iOS using
JMAP.

In a clustered setup this exposes the internal node name and may result in a
non-FQDN right-hand side of the Message-ID.

Example cluster:

  • mail-srv01
  • mail-srv02
  • mail-srv03

Configured public/default server hostname:
mail.example.com

A message sent from Mailtemi on iOS through JMAP and handled by mail-srv02
resulted in:

Message-ID: <18d04c249f782f46.ef74ff620c533f2.8614027a305116aa@mail-srv02>

The receiving Rspamd instance consequently reported:
MID_RHS_NOT_FQDN(0.50)

The message otherwise passed SPF, DKIM and DMARC.

Expected Behavior

When Stalwart generates a Message-ID for a JMAP-created message, the
right-hand side should use the configured public/default server hostname, for
example:

Message-ID: <[email protected]>

The internal cluster node hostname should not be exposed in externally visible
Message-IDs.

A client-supplied Message-ID should remain unchanged.

Actual Behavior

When the JMAP client does not provide a Message-ID, the generated Message-ID
uses the operating system/container hostname of the Stalwart node that processed
the request.
For example:
Message-ID: <18d04c249f782f46.ef74ff620c533f2.8614027a305116aa@mail-srv02>
instead of:
Message-ID: <[email protected]>

In this setup the values are intentionally different:
internal node hostname:
mail-srv02

public/default server hostname:
mail.example.com

The individual node hostnames distinguish the nodes within the cluster, while
mail.example.com represents the public server identity.

The generated Message-ID caused the receiving Rspamd instance to assign:
MID_RHS_NOT_FQDN(0.50)

Reproduction Steps

  • Run Stalwart in a clustered setup with an OS/container hostname such as:
    mail-srv02
  • Configure the public/default Stalwart server hostname as:
    mail.example.com
  • Configure Mailtemi on iOS to use the Stalwart server via JMAP.
  • Compose and send a message from Mailtemi.
  • The client does not supply its own Message-ID.
  • Inspect the delivered message at the receiving mail server.
  • Observe that the generated Message-ID ends in:
    @mail-srv02
    instead of:
    @mail.example.com

Stalwart Version

v0.16.x

Installation Method

Docker

Database Backend

PostgreSQL

Blob Storage

S3-compatible

Search Engine

PostgreSQL

Directory Backend

Internal

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Fixed in v0.16.20 (yet to be released).