@climber-girl noticed some cases where the text [Errno 97] Address family not supported by protocol appears in the trustymail output. I dug into this, and it appears to happen because, when given a hostname to connect to, smtplib asks DNS for all A and AAAA records, tries them in succession, and uses the first one that works.
When running trustymail in AWS Lambda (at least in my VPC, which doesn't support IPv6) the [Errno 97] Address family not supported by protocol error appears when an IPv6 connection is attempted. This makes the connection attempt fail hard, and the other IP addresses returned by DNS are not even attempted.
To get around this, I explicitly get an IPv4 address for the hostname and pass that to smtplib instead. This way no IPv6 connections are ever attempted.
@climber-girl noticed some cases where the text
[Errno 97] Address family not supported by protocol
appears in thetrustymail
output. I dug into this, and it appears to happen because, when given a hostname to connect to,smtplib
asks DNS for all A and AAAA records, tries them in succession, and uses the first one that works.When running trustymail in AWS Lambda (at least in my VPC, which doesn't support IPv6) the
[Errno 97] Address family not supported by protocol
error appears when an IPv6 connection is attempted. This makes the connection attempt fail hard, and the other IP addresses returned by DNS are not even attempted.To get around this, I explicitly get an IPv4 address for the hostname and pass that to smtplib instead. This way no IPv6 connections are ever attempted.