Skip to content

SMTP send has no timeout, a stalled host stops all outbound email #373

Closed

Description

@cavidelizade

Summary

Sending email has no dial or IO timeout, so a SMTP host that accepts the TCP connection but never responds blocks the email worker forever and stops all outbound mail.

Where

internal/mail/mail.go, sendMailWithConfig: neither tls.Dial (port 465 path) nor smtp.SendMail is given a timeout, and neither respects the passed ctx. The email queue is drained by a single consumer goroutine that processes one message at a time (internal/queue/consumer.go, cmd/api/main.go).

Impact

If the configured SMTP host black-holes the connection (a common firewall failure mode), the send blocks indefinitely, the QueueEmails consumer never returns, and every invite, password reset, magic code, and notification email stops until the process is restarted. Context cancellation on shutdown won't unblock it either.

Suggested fix

Dial with a timeout (net.Dialer with a deadline for the TLS path, and a smtp.Client built on a timed net.Dial for the STARTTLS path), and honor ctx.

Activity

  1. martian56 commented on Oct 25, 2026

    @martian56
    Member

    Fixed by #405: SMTP sends now use context-aware dialing with a 15s deadline, so a stalled host can no longer block outbound email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions