3

Log

to=<x.y@example.com>, relay=none, delay=21311, delays=21301/0.04/10/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=localdomain type=MX: Host not found

OS: FreeBSD

When I run the following command on my postfix client, it does resolve. mail.p.example.com hosts our postfix server, which then relays emails to gmail smtp.

host -t MX p.example.com
p.example.com mail is handled by 10 host.p.example.com.

I compare my postfix config with a working config on another host and they're the same.

inet_protocols = ipv4
mynetworks_style = host
inet_interfaces = loopback-only
relayhost = $mydomain

There's more to the config than what I pasted above but nothing related to dns. smtp_host_lookup hasn't been set (default value = dns).

I do not have any resolv.conf files under /var/spool/postfix. Would appreciate any directions on how postfix resolves DNS records.

pdna
  • 209
  • 4
  • 10
  • The domain you looked up with `host -t MX` is _not_ the domain you sent mail to. – Michael Hampton Jan 18 '19 at 00:54
  • So the email was sent to the domain example.com, which has been whitelisted in transport db. The domain I looked up is an environment in example.com. I do not understand how the receiver domain matters here in terms of DNS resolution. I updated the ticket with more details "When I run the following command on my postfix client, it does resolve. mail.p.example.com hosts our postfix server, which then relays emails to gmail smtp." Also updated the receiver address in log. – pdna Jan 18 '19 at 03:38

2 Answers2

2

Aha, now the problem is obvious:

relayhost = $mydomain

You have configured Postfix to deliver all mail to $mydomain, which is set to localdomain.

Your narrative indicates you meant to be relaying mail to Gmail, so your relayhost should be set to the appropriate Google hostname for that purpose, e.g.:

 relayhost = [smtp-relay.gmail.com]:25

or

 relayhost = [smtp-relay.gmail.com]:587

and your smtp_sasl_password_maps should point to a file containing your Gmail credentials, if you are using SMTP authentication.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • Let me clarify my statement again. All postfix clients in the environment forward emails to the mail server, which then forwards them to [smtp-relay.gmail.com]:587. The log here is from a postfix client. Its not even hitting the internal mail server – pdna Jan 18 '19 at 03:53
  • But I can check what $mydomain is set to. I have been thinking it resolves via dns or something. – pdna Jan 18 '19 at 03:54
  • So this is not the postfix server that relays to Gmail, but to another postfix server? Definitely check relayhost and set it to the correct value. $mydomain will never be it. – Michael Hampton Jan 18 '19 at 03:54
  • Yes. There is only server in the environment that can relay to smtp-gmail. The config is working on other hosts. I did an md5 comparison on configs – pdna Jan 18 '19 at 03:56
  • Set relayhost to point to that server, then. I have no idea how $mydomain would work on any other server, since that is not likely to be the name of the server, and even if it was, it would probably be semantically wrong. – Michael Hampton Jan 18 '19 at 03:56
  • mydomain is supposed to resolve to mail.p.example.com – pdna Jan 18 '19 at 03:57
  • All your email addresses end in @mail.p.example.com? That seems unlikely. But if mail.p.example.com is actually the FQDN for that server, then just specify that literally. – Michael Hampton Jan 18 '19 at 03:59
  • Email addresses do not necessarily end in @mail.p.example.com I thought I specified it specifically when I showed the MX record resolving to postfix server. – pdna Jan 18 '19 at 04:00
  • But that's what $mydomain refers to, what your email addresses end with. So it's probably set wrong on all your other servers too. – Michael Hampton Jan 18 '19 at 04:02
  • $mydomain doesn't refer to "what your email addresses end with". Here's the definition of it from postfix docs. relayhost = $mydomain "deliver via local mailhub" – pdna Jan 18 '19 at 04:05
  • And the $mydomain is working on other postfix clients. So there is something specific to this postfix client/host thats causing issues. – pdna Jan 18 '19 at 04:06
  • I may have found the issue. `hostname -f ` isn't resolving to FQDN on the host thats causing issues. its only resolving to shortname. On the hosts where postfix clients are working, its resolving to FQDN. – pdna Jan 18 '19 at 04:18
  • yep, that fixed the issue. thanks for taking a look. – pdna Jan 18 '19 at 04:21
0

hostname -f wasn't resolving to FQDN on the host thats causing issues. its only resolving to shortname. On the hosts where postfix clients are working, its resolving to FQDN

hostname was already set under /etc/rc.conf.d/hostname. I just had to restart hostname service. guess someone manually set the hostname/domainname by running commands instead of using configuration management tools.

pdna
  • 209
  • 4
  • 10