At 14:02 -0700 on 04/05/2008, Russ Allbery wrote about Re: current
usage of AAAA implicit MX?:
In fact, from that perspective, it would be a bit annoying to write a
fallback to A without also writing a fallback to AAAA for hosts without an
MX record. The obvious (at least with thirty seconds of thought, and I
may be missing gotchas) way of implementing resolution of a mail server is
to do an MX record lookup and, if that fails, call getaddrinfo on the RHS
and connect to the resulting addresses until one of them works. This
would treat AAAA identically to A.
Your implementation problem is simple to fix.
1) Look for MX.
2) If no MX found set NO-MX flag and do getaddrinfo.
3) If NO-MX and IPN=IPv6 Address skip address otherwise try address.
4) If Step 3 skipped address or address failed redo step 3 with next
address until you run out of addresses.
What is so hard about looking at the IPN format before trying it WHEN
you used getaddrinfo due to the lack of an MX?