Skip to content

fix(messenger): configurable SMTP timeout (#278) - #203

Merged
tina4stack merged 2 commits into
v3from
fix/issue-278-smtp-timeout
Oct 9, 2026
Merged

tina4stack merged 2 commits into
v3from
fix/issue-278-smtp-timeout

Conversation

@tina4stack

Copy link
Copy Markdown
Owner

Reproduced + fixed tina4-python#278 (reference). The SMTP send timeout was hardcoded 30s with no config; a silent host held a worker 30s. Adds a timeout constructor arg + TINA4_MAIL_TIMEOUT (SMTP_TIMEOUT fallback), default 30. No-mock test (real silent TCP server; 1s timeout fails in ~1s). php/ruby/node ports follow. Closes #278.

The SMTP send timeout was hardcoded at 30 s (_smtp_open(timeout=30)) with no
constructor argument or environment key, so a host that accepts the connection
then goes silent held the worker for the full 30 s - and on a server with few
workers that stalls everyone else. Add a `timeout` constructor argument and a
TINA4_MAIL_TIMEOUT env (SMTP_TIMEOUT fallback), default 30 (unchanged), used on
the send path. The 10 s capability check is left as the fast can-send gate.

Reference implementation for the cross-framework fix (php/ruby/node follow).

Test (no mocks): a real TCP server that accepts then never replies - a 1 s
timeout fails the send in ~1 s instead of ~30 s, via the constructor and via the
env; the default stays 30 and a bad value falls back to 30.

Fixes #278

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Tina4 <82961293+tina4stack@users.noreply.github.com>
Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
…278)

Re-base the timeout resolution on MichaelC8E's PHP #286 (now the reference
for this issue) so all four frameworks behave the same:
- priority is constructor > TINA4_MAIL_TIMEOUT > 30; the SMTP_TIMEOUT
  fallback is dropped.
- an explicit constructor value below 1 second RAISES (a programming
  error), rather than silently coercing to the default.
- a garbage or < 1 env value warns ONCE and uses the default 30 (0 is
  garbage, not an opt-out: to the socket it means do-not-wait).
- a silent server is already reported AS a timeout (smtplib surfaces
  socket.timeout -> 'timed out' in the result message); the test now
  asserts it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
@tina4stack
tina4stack merged commit a70d153 into v3 Oct 9, 2026
15 checks passed
@tina4stack
tina4stack deleted the fix/issue-278-smtp-timeout branch October 12, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants