Some remote SMTP server I am trying to deliver mail to refuses to accept the HELO from my server:
504 5.5.2 <localhost>: Helo command rejected: need fully-qualified hostname
Apparently, my Exim4 server sends localhost as its FQDN. Searching the net and a bunch of config files, I have learned that the value sent as FQDN during HELO is drawn from the primary_hostname configuration variable.
My question is: what is the correct way to change this variable in a Debian system? I guess I can simply hardcode a value in on of the Exim4 config files, but IMHO it would seem to make more sense if the value automagically corresponded to /etc/mailname or some other centralized name config.
I have a feeling that the answer to my question can be found in this text from the Debian wiki:
The name used by Exim in EHLO/HELO is pulled from configuration option
primary_hostname. Debian's exim4 default configuration does not setprimary_hostname. Exim then defaults to uname() to find the host name. If that call only returns one component, gethostbyname() or getipnodebyname() is used to obtain the fully qualified host name.If your Exim HELOs as localhost.localdomain, then you have most probably a misconfigured /etc/hosts created by some versions of the Debian installer. In this case, please fix your /etc/hosts.
Unfortunately, I am not familiar enough with Linux server administration to know exacly what all this means :(
hostname -fstill reports "localhost". The part about /etc/hosts in your answer seems buggy - what is the first record supposed to look like? – Jørn Schou-Rode Jul 27 '09 at 16:08hostname -fstill reports "localhost", it seems that the change to /etc/hostname did the trick - I am able to deliver my mail now. I still would like to see the missing part of your post though :) – Jørn Schou-Rode Jul 27 '09 at 16:15/etc/hostnamedoesn't typically contain the FQDN on Debian systems, only the short hostname. – Josip Rodin Dec 18 '17 at 20:08/etc/hostsmight be127.0.0.2 mydomain.com myhostname(127.0.0.2works as well as127.0.0.1, since loopback is a class A network). You can probably combine the two lines into one127.0.0.1 mydomain.com myhostname localhost, butlocalhostis a canonical hostname for127.0.0.1, isn't it? That all given that you have hostname, not FQDN as your hostname. Also, changing/etc/hostnamedoesn't take effect immediately, you've got tohostname myhostname. Or restart server. – x-yuri May 02 '19 at 05:33