DevHeads.net

How to make Postfix use hostnames from /etc/hosts ?

As I have trouble with sending emails to Gmail (I wrote about it in a
different thread), I try to configure Postfix to send mail to Gmail via a
different mail server as a relay. However, for reasons too long to explain
here, I would like Postfix to refer to that server via hostname that I
defined in /etc/hosts file and not via actual DNS hostname.

My first attempt, with using the following line in the transport map:

gmail.com smtp:[aws]

where "aws" is the host name defined in /etc/hosts, resulted in failure
to send email, with the following error message from Postfix:

<......@gmail.com>: Host or domain name not found. Name service error for
name=aws type=AAAA: Host found but no data record of requested type

I found in the documentation that I have to add the parameter
"smtp_host_lookup=native" to main.cf to make Postfix use system configured
name resolution instead of trying to resolve names by itself. So I did it,
reloaded Postfix and got the following error:

<......@gmail.com>: unable to look up host aws: No address associated with
hostname

So I tried to change the name both in the transport map and in /etc/hosts
file from "aws" to "aws.local" to make it look more like a domain name :).
This time I got the following:

<......@gmail.com>: unable to look up host aws.local: Name or service not
known

What am I doing wrong?

Comments

Re: How to make Postfix use hostnames from /etc/hosts ?

By Jaroslaw Rafa at 10/07/2019 - 18:54

Dnia 8.10.2019 o godz. 00:09:34 Jaroslaw Rafa pisze:
Replying to myself, but it looks that the issue is solved - I need to
*restart* Postfix after these changes, only reloading is not enough.

(However, it didn't help with my original Gmail issue - even mail relayed
via another server still goes to spam on the receiving side :()

Re: How to make Postfix use hostnames from /etc/hosts ?

By Rich Shepard at 10/07/2019 - 19:00

Jaroslaw,

While not directly related to your issue, I've found that some clients who
use gmail end up with messages I send in their spam folder. Many folks use
gmail and only a few have had this problem. I'm certain that it's an issue
with their ISP and not postfix or google (directly).

They'll call and ask why they've not received the information they requested
and I ask them to look in their spam folder. Sure enough, there sits the
original message (and attachments) I sent. That they don't think of looking
there on a daily basis, or when not receiving expected communications, is a
non-technical issue.

Glad you fixed your problem.

Rich