I have Postfix running on an Ubuntu 16.04 server for Gitlab and I am able to send email out to most domains except my corporate domain. From what I can tell, Postfix never tries the mail server IP address under my domain. For this example, say my email is skrawn@company.com and the mail server is at 11.101.1.40. The Postfix mail log reports:
Jan 5 10:05:10 linux-dev postfix/smtp[2058]: connect to company.com[11.202.17.1]:25: Connection timed out
Jan 5 10:05:40 linux-dev postfix/smtp[2058]: connect to company.com[11.101.1.46]:25: Connection timed out
Jan 5 10:06:10 linux-dev postfix/smtp[2058]: connect to company.com[11.101.56.8]:25: Connection timed out
So it's not even trying the actual mail server at 11.101.1.40. I search around and saw suggestions of editing the /etc/hosts file to manually map the domain to the correct IP. So in my hosts file, I added:
11.101.1.40 company.com
Then to make Postfix use the hosts file as well as the DNS servers, I add this to /etc/postfix/main.cf:
smtp_host_lookup=dns, native
Reloaded postfix, restarted the server, etc. Postfix is still not trying the mail server IP.
So, I changed the /etc/postfix/main.cf to
smtp_host_lookup=native
And it works!
Jan 5 10:22:27 linux-dev postfix/smtp[1317]: 9DBC61A405FB: to=<skrawn@company.com>, relay=company.com[11.101.1.40]:25, delay=90665, delays=90664/0.04/0.51/0.26, dsn=2.0.0, status=sent (250 Message accepted for delivery)
Ok, so maybe I just need to change the smtp_host_lookup so it checks native first:
smtp_host_lookup=native, dns
No luck. It sill won't try 11.101.1.40. Any ideas on what I am missing the configuration? I'd like to be able to send emails both to that mail server and to other domains. Thank you for any help!
dig mx yourcompany.com
orhost yourcompany.com
?$ dig mx company.com ; <<>> DiG 9.10.3-P4-Ubuntu <<>> mx company.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11315 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4000 ;; QUESTION SECTION: ;company.com. IN MX ;; AUTHORITY SECTION: company.com. 699 IN SOA company.com. admin. 24380 900 600 86400 3600 ;; Query time: 0 msec ;; SERVER: 10.85.0.2#53(10.85.0.2) ;; WHEN: Thu Jan 05 10:43:01 MST 2017 ;; MSG SIZE rcvd: 96
$ host company.com company.com has address 11.101.56.8 company.com has address 11.101.1.46 company.com has address 11.202.17.1