You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lists:map(fun(X) -> {10, inet_parse:ntoa(X)} end, inet_res:lookup(Domain, in, a));
Proposed solutions
So it seems like OTP does not provide an easy way to do this. What we can do instead is to:
A: manually resolve MX - A/AAAA records and try them one-by-one.
B: call gen_tcp:connect("example.com", 25, [inet6]) and if that fails gen_tcp:connect("example.com", 25, [inet]).
Both are quite intrusive changes I would say (can increase latency), so, probably should be turned on by some option? Say {ip_versions, [inet:address_family()]} - this way one can define both priority (elements in a list are tried one-by-one) and can enable/disable ip families by not including to a list.
Also, smth should be done with smtp_util:mxlookup. Either we always return all IPs from MX and A or we just return unresolved domain from mxlookup fallback.
The text was updated successfully, but these errors were encountered:
seriyps
changed the title
Transparently try to both ipv6 and ipv4 in gen_smtp_client
Transparently try both ipv6 and ipv4 in gen_smtp_client
Jun 3, 2020
Why?
Well, shortage of ipv4 addresses. More flexibility. But at the same time, not all mail receivers support ipv6, so, you can't just be ipv6-only
Problem
gen_smtp_client
usesgen_tcp:connect/3
and this one always uses ipv4:It's possible to tell gen_tcp which protocol to use by providing
inet
orinet6
options, but if you'll provide both, only 1st one will be used:Also,
smtp_util:mxlookup
explicitly resolvesA
dns if noMX
is found and ignoresAAAA
ones.gen_smtp/src/smtp_util.erl
Line 52 in 62f585b
Proposed solutions
So it seems like OTP does not provide an easy way to do this. What we can do instead is to:
A: manually resolve MX - A/AAAA records and try them one-by-one.
B: call
gen_tcp:connect("example.com", 25, [inet6])
and if that failsgen_tcp:connect("example.com", 25, [inet])
.Both are quite intrusive changes I would say (can increase latency), so, probably should be turned on by some option? Say
{ip_versions, [inet:address_family()]}
- this way one can define both priority (elements in a list are tried one-by-one) and can enable/disable ip families by not including to a list.Also, smth should be done with
smtp_util:mxlookup
. Either we always return all IPs from MX and A or we just return unresolved domain from mxlookup fallback.The text was updated successfully, but these errors were encountered: