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 firstname.lastname@example.org and the mail server is at 126.96.36.199. The Postfix mail log reports:
Jan 5 10:05:10 linux-dev postfix/smtp: connect to company.com[188.8.131.52]:25: Connection timed out Jan 5 10:05:40 linux-dev postfix/smtp: connect to company.com[184.108.40.206]:25: Connection timed out Jan 5 10:06:10 linux-dev postfix/smtp: connect to company.com[220.127.116.11]:25: Connection timed out
So it's not even trying the actual mail server at 18.104.22.168. 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:
Then to make Postfix use the hosts file as well as the DNS servers, I add this to /etc/postfix/main.cf:
Reloaded postfix, restarted the server, etc. Postfix is still not trying the mail server IP.
So, I changed the /etc/postfix/main.cf to
And it works!
Jan 5 10:22:27 linux-dev postfix/smtp: 9DBC61A405FB: to=<email@example.com>, relay=company.com[22.214.171.124]: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:
No luck. It sill won't try 126.96.36.199. 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!