-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
🐛 IPv6 binding issue with SMTPServer::Server
The current SMTP server only binds to IPv4 (AF_INET) sockets, making it impossible to listen on IPv6 addresses such as :: or to accept dual-stack connections (IPv6 + IPv4).
When using a config like:
smtp_server:
default_bind_address: "::"
default_port: 25
Postal fails to start or doesn’t accept connections on IPv6 interfaces.
Expected behavior
The SMTP server should be able to bind to both IPv4 and IPv6 addresses when configured with ::, similar to how modern mail servers handle dual-stack operation.
To reproduce
1. Set default_bind_address: "::" in the configuration file.
2. Start Postal.
3. Observe that the server either:
• Fails with a “Cannot assign requested address” error, or
• Listens only on IPv4-mapped connections.
Technical analysis
TCPServer.open(bind_address, port) in Ruby only opens an IPv4 socket.
Ruby doesn’t automatically create a dual-stack socket unless explicitly requested via AF_INET6.
Therefore, Postal’s current code cannot handle IPv6-only or dual-stack setups.
Proposed fix
Modify the listen method in SMTPServer::Server to support IPv6, by explicitly opening both sockets when needed:
["::", "0.0.0.0"].uniq.each do |addr|
s = TCPServer.new(addr, port)
...
end
This ensures proper IPv6 compatibility on systems where net.ipv6.bindv6only=1.
Environment
• OS: Ubuntu/Debian docker
• IPv6 enabled: yes