Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Synapse can't connect to an IPv6-only mail server via hostname #7720

@sandhose

Description

@sandhose

Description

Synapse only does IPv4 address resolution for the email.smtp_host when sending email.
This might be (arguably) an issue on Twisted side though.

Internally, our SMTP server is accessible only with IPv6 (because dual-stack services is not a thing in Kubernetes right now) ; while we could probably work around, I think it's still a bug worth fixing, because IPv6-only environments/clouds are getting more and more traction.

Steps to reproduce

  • have a SMTP host with only an IPv6 (AAAA) entry
  • configure it as the email.smtp_host on Synapse
  • try to send an email

Here is the error we got from Sentry:

DNSLookupError: DNS lookup failed: postfix.mail.svc.cluster.local.
  File "synapse/handlers/identity.py", line 350, in send_threepid_validation
    await send_email_func(email_address, token, client_secret, session_id)
  File "synapse/push/mailer.py", line 207, in send_add_threepid_mail
    template_vars,
  File "synapse/push/mailer.py", line 323, in send_email
    requireTransportSecurity=self.hs.config.require_transport_security,

Additional informations

I figured that Synapse was only doing A resolution by capturing on the container net interface. I wondered why this was the case for SMTP but not in other parts like the federation HTTP client.

It seems that it is because Synapse uses twisted.mail.smtp.sendmail to send emails without doing explicit DNS resolution first, and sendmail directly does a reactor.connectTcp which chooses the address type (IPv4 or IPv6) based on the host. Because the host supplied to sendmail is a hostname and not an IP, Twisted considers it is an IPv4, not an IPv6.

I'm not sure if that should be fixed on Synapse or Twisted side.

Version information

  • Homeserver: not matrix.org
  • Version: 1.15.1
  • Install method: Kubernetes/docker image
  • Platform: Containers on bare-metal

cc @ludovicm67, my colleague who found this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Email-PushEmail notificationsS-MinorBlocks non-critical functionality, workarounds exist.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.Z-Upstream-BugThis issue requires a fix in an upstream dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions