[New-bugs-announce] [issue14758] SMTPServer of smptd does not support binding to an IPv6 address

Ivan Sergeev report at bugs.python.org
Tue May 8 23:15:50 CEST 2012

New submission from Ivan Sergeev <vsergeev at gmail.com>:

The SMTPServer class of the smtpd module creates a server socket with the IPv4 socket.AF_INET address family hardcoded, and this prevents it from later binding to an IPv6 local address.

This occurs on line 282 of smtpd.py for the Python 2.7 branch:

And on line 435 of smtpd for the Python 3.2 branch ( Lib/smtpd.py:435 ):

One IPv4/IPv6 agnostic solution is to look up provided local address with getaddrinfo(), and use one of the result's address family, socket type and address tuple for create_socket() and bind() at those lines:

    gai_results = socket.getaddrinfo(localaddr[0], localaddr[1])
    self.create_socket(gai_results[0][0], gai_results[0][1])
    # try to re-use a server port if possible

components: Library (Lib)
messages: 160226
nosy: vsergeev
priority: normal
severity: normal
status: open
title: SMTPServer of smptd does not support binding to an IPv6 address
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list