I've configured my mail server for IPv6 and IPv4 but in the most cases it uses IPv4 while IPv6 is available on the remote host. I use Postfix in version 2.9. So my thought was that postfix uses IPv6 if available and has a fallback to IPv4 or am I wrong?
Have you set the smtp_address_preference option to expliclity prefer IPv6?
smtp_address_preference (default: any)
The address type ("ipv6", "ipv4" or "any") that the Postfix SMTP client will try first, when a destination has IPv6 and IPv4 addresses with equal MX preference. This feature has no effect unless the
inet_protocols setting enables both IPv4 and IPv6. With Postfix 2.8 the default is "ipv6".
Notes for mail delivery between sites that have both IPv4 and IPv6 connectivity:
· The setting "smtp_address_preference = ipv6" is unsafe. It can fail to deliver mail when there is an outage that affects IPv6, while the destination is still reachable over IPv4.
· The setting "smtp_address_preference = any" is safe. With this, mail will eventually be delivered even if there is an outage that affects IPv6 or IPv4, as long as it does not affect both.
This feature is available in Postfix 2.8 and later.
Granted that Postfix is correctly configured with IPv6, it is instructed to use both protocols and the MX host it connects to has both A and AAAA record, Postfix makes a random choice every time, as Wietse Wenema himself explained:
Recent Postfix SMTP clients randomly select between IPv4 and IPv6 so that mail won't get stuck when one of the two is down.