Skip to content

An SMTP server that never sends its greeting makes an email send hang #2039

Open

Description

@AmanGIT07

pkg/mailer sends through gopkg.in/mail.v2 v2.3.1. Its Dialer.Dial reads the server greeting (smtp.go:91) before it sets the connection deadline (smtp.go:96-98). If the SMTP server accepts the connection but never sends its greeting, the send blocks with no deadline.

Every email goes through this path: the login OTP (core/authenticate/strategy/mail_otp.go:95) and magic link (core/authenticate/strategy/mail_link.go:75), invitations (core/invitation/service.go:222), PAT alerts (core/userpat/alert_service.go:244), and the organization delete email (core/deleter/delete_notice.go:249). #2034 adds the user delete email on the same path. Most of these send inside a request, so the request blocks with the send.

It needs a mail server that accepts the connection and then stays silent, so it is rare.

Possible fixes:

  • Set the deadline right after the connection opens. The library exposes its dial as mail.NetDialTimeout (smtp.go:77), so pkg/mailer can wrap it once at startup.
  • Move to an SMTP library whose send takes a context.

Activity

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