28

I've just installed Postfix on my Ubuntu, on a local network.

On this network, I have an Exchange Server (using domain mail.example.com). I had a problem sending an email to a local address: adress@example.com:

relay=none, delay=0.01, delays=0.01/0/0/0, dsn=4.3.5, status=deferred 
(Host or domain name not found. Name service error for name=example.com
type=AAAA: Host found but no data record of requested type)

I solved this problem using relay_domain in my Postfix main.cf:

relay_domains = example.com
transport_maps = hash:/etc/postfix/transport

And in my /etc/postfix/transport:

example.com smtp:[mail.example.com]

Now I can send mails on @example.com, and I have tested some majors webmails (Gmail, Yahoo, Hotmail...). It works. But why I got this error on my adresses @example.com? How can I be sure I never find this error on another domain?

My Postfix configuration is:

postconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = SRVWEB, localhost.localdomain, localhost
myhostname = SRVWEB
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relay_domains = domain.com
relayhost =
smtp_generic_maps = hash:/etc/postfix/generic
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = hash:/etc/postfix/transport
Vincent LITUR
  • 405
  • 1
  • 6
  • 9

5 Answers5

39

Your server is trying to use IPv6 when sending the mail. Since the mail.example.com doesn't have an AAAA-record (which is the same as an A-record, but for IPv6), that isn't working.

If you want Postfix to never use IPv6, you can change that in the config file, as explained in the postconf(5) man page:

When IPv6 support is enabled via the inet_protocols parameter,  Post-
fix will do DNS type AAAA record lookups.

When  both IPv4 and IPv6 support are enabled, the Postfix SMTP client
will attempt to connect via IPv6 before attempting to use IPv4.

Examples:

inet_protocols = ipv4
inet_protocols = all (DEFAULT)
inet_protocols = ipv6
inet_protocols = ipv4, ipv6

If you want to change it for this domain only, change your transport map to read

example.com smtp-ipv4:[mail.domain.com]
Giacomo1968
  • 3,542
  • 27
  • 38
Jenny D
  • 27,780
  • 21
  • 75
  • 114
  • Thanks for this explanation ! I read a documentation in French which said that ipv4 was the DEFAULT configuration.. I put ipv4 now, and I have reloaded Postfix, seems to work. Thanks again ! – Vincent LITUR Feb 21 '14 at 08:57
  • It depends on which version of Postfix you're using - I don't recall which version defaults to which, but I know they changed it around at least once. – Jenny D Feb 21 '14 at 08:57
  • 8
    It's not the connection that fails, but the DNS lookup that precedes it. When I have `inet_protocols = all` it does not attempt an `A` lookup if an `AAAA` lookup fails, which seems pointless. Also, if you change this value, you must restart postfix, not just reload. – Synchro Feb 26 '15 at 11:51
2

I able to resolve it by telling to Postfix to use Google DNS , right after Installing postfix:

echo 'nameserver 8.8.8.8' >> /var/spool/postfix/etc/resolv.conf
1

The simple Postfix configuration that worked for me.

/etc/postfix/main.cf

myhostname = localhost.testing.com
myorigin = testing.com
relayhost =
inet_protocols = ipv4
inet_interfaces = loopback-only
mydestination =
Colt
  • 2,029
  • 6
  • 21
  • 27
joseph
  • 11
  • 3
0

The following change in /etc/postfix/main.cf solved the problem for me.

disable_dns_lookups = yes
Paul
  • 3,037
  • 6
  • 27
  • 40
Andrey
  • 1
-4

The following change in /etc/postfix/main.cf solved the problem for me.

inet_protocols = ipv6 

Change the above to

inet_protocols = all
selche
  • 17
  • 2
  • 9
    Doesn't add much to the accepted answer, and, to be frank, is useless without JennyD's post which provides the **explanation**. – Deer Hunter Nov 12 '14 at 09:27