dataTimeout doesn't cover the reply after the message

Issue Description

Stalwart 1.0.3 (8b32686). The docs (mta/outbound/connection.md) describe dataTimeout as “Reply after the message data”, default 10 minutes. The wait for that reply actually uses rcptToTimeout.

Expected Behavior

As documented, dataTimeout covers the reply after the message data; or the docs say that rcptToTimeout does.

Actual Behavior

Test, 1 run: the receiver takes the message and stalls 150 s after the final dot, then answers 250.

rcptToTimeout dataTimeout Result Receiver got it
60 s 300 s Dropped at 60,186 ms, “Timeout while reading SMTP DATA response”, retried Twice
300 s 60 s Waited, delivered Once

Reproduction Steps

  1. A receiving server that reads the message and stalls 150 s after the final dot before answering 250.
  2. MtaConnectionStrategy: rcptToTimeout 60 s, dataTimeout 300 s. ReloadSettings. Send one message: dropped at 60 s, sent again on retry.
  3. rcptToTimeout 300 s, dataTimeout 60 s. ReloadSettings. Send one message: waits, delivered once.

Relevant Log Output

2026-11-05T07:00:56Z INFO Message rejected by remote server (delivery.message-rejected) queueName = "remote", size = 231, total = 1, causedBy = SMTP error occurred (smtp.error) { details = "Connection Error", reason = "Timeout while reading SMTP DATA response" }, elapsed = 60186ms

Some fields removed: addresses, hostname, queue ID.

Stalwart Version

v1.x

Installation Method

Binary (Linux)

Database Backend

PostgreSQL

Blob Storage

S3-compatible

Search Engine

PostgreSQL

Directory Backend

Internal

Additional Context

Read in source: read_smtp_data_response uses self.timeout (crates/smtp/src/outbound/client.rs:139-146), last set to timeout_rcpt at session.rs:191. timeout_data wraps only DATA, the 354 and writing the body (client.rs:224).

So lowering the RCPT timeout, which looks harmless, causes duplicates with receivers that scan after DATA, and raising dataTimeout doesn’t help. Is this intended? If not, could that reply use dataTimeout? If it is, could the docs say so?

Tested and written with AI help.

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

Let me verify the source.

This looks like a real mismatch between the docs and the code, not intended behaviour. I confirmed your reading in the source.

read_smtp_data_response in crates/smtp/src/outbound/client.rs waits with self.timeout. In crates/smtp/src/outbound/session.rs, smtp_client.timeout is set to params.conn_strategy.timeout_rcpt at line 191. I found no later assignment to timeout_data before read_smtp_data_response is called at line 315. timeout_data only wraps send_message in client.rs. That covers sending DATA, reading the 354, and writing the body. It does not cover the final reply after the closing dot.

So today the wait for the final reply is bounded by rcptToTimeout. The docs say otherwise. mta/outbound/connection lists dataTimeout as “Reply after the message data”. I found nothing in the docs that says rcptToTimeout applies there. Your table matches the code. With rcptToTimeout at 60 s, the sender gives up on a 150 s reply, retries, and the receiver gets the message twice.

Until this is resolved, keep rcptToTimeout at least as high as the longest post-DATA delay you expect from receivers that scan after DATA. Raising dataTimeout alone won’t change this behaviour.

I can’t say whether staff will fix it in code, by using dataTimeout for that reply, or in the docs. A human will follow up on that.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

This was a bug in the outbound client. After sending the message body it kept reading the final reply with the timeout left over from the RCPT stage, so rcptToTimeout decided how long Stalwart waited after the dot and dataTimeout only covered sending DATA and the body. Your two runs show exactly that. The docs describe the intended behaviour, so they stay as they are.

The fix makes the reply after the message data (and the per-recipient replies in LMTP) use dataTimeout. It ships in the next weekly Stalwart release.

Until you’re on that release, raise rcptToTimeout in the connection strategy to at least the longest time your receiver spends scanning after the final dot, as your 300 s run already showed. It also applies to the RCPT TO replies, so a slow receiver at that stage would be waited on longer too.