@@ -173,9 +173,28 @@ def starttls_scan(domain, smtp_timeout, smtp_localhost, smtp_ports, smtp_cache):
173173 # To get around this I look up the A record and use
174174 # that instead of the hostname in DNS when I call
175175 # smtp_connection.connect().
176- addr_info = socket .getaddrinfo (
177- mail_server , port , socket .AF_INET , socket .SOCK_STREAM
178- )
176+ try :
177+ addr_info = socket .getaddrinfo (
178+ mail_server , port , socket .AF_INET , socket .SOCK_STREAM
179+ )
180+ except socket .gaierror :
181+ # We get this exception if there is no A record
182+ # for the given mail server. This does happen,
183+ # since among their MX records some domains do
184+ # list some IPv6-only mail servers.
185+ #
186+ # Since we can't evaluate such cases we will
187+ # simply log this and give them credit. One of
188+ # the other mail servers will support IPv4.
189+ error_str = f'The mail server { mail_server } does not have an IPv4 address.'
190+ handle_error ('[STARTTLS]' , domain , error_str )
191+ logging .warn (error_str )
192+ domain .starttls_results [server_and_port ]['is_listening' ] = True
193+ domain .starttls_results [server_and_port ]['supports_smtp' ] = True
194+ domain .starttls_results [server_and_port ]['starttls' ] = True
195+ continue
196+
197+ # Extract the IP address from the socket addrinfo
179198 socket_address = addr_info [0 ][4 ]
180199 mail_server_ip_address = socket_address [0 ]
181200
0 commit comments