Incorrect hostnames on Linux (and occasionally with xBSD, such as FreeBSD, NetBSD, OpenBSD etc) often lead to problems both with the CBL, and with hosted spam filters that insist on RFC821/RFC2821/RFC5321 compliance.
This will most frequently appear with sendmail systems that are uttering a helo of "localhost.localdomain" or single-token hostnames like "mail", and the headers in sent email will be inappropriately sprinkled with it. Up to and including From lines that have localhost.localdomain instead of your real domain. Clearly that's not working properly.
There can be similar issues with Exim, Postfix, Sendmail and Qmail or any other Linux/xBSD email system.
It all has a common cause: the machine's name is not set right.
Most of this is due to poor understanding of and idiosyncracies in install or configuration change procedures. It confuses the experts because every flavour of UNIX is different, but hopefully, this page will assist with machines intended to be used as mail servers.
This page attempts to describe how to make sure that everything is right.
In this page, "example.com" is used as your domain, "mail.example.com" is used as the hostname you want your machine to be, and 220.127.116.11 is your static IP (assuming that you have one).
WARNING: This page is specifically intended to assist in getting Linux/xBSD mail servers to know their own name properly. Situations where you'd not normally want to run a mail server (eg: the machine is on dynamic IP addresses or WIFI strangeness) are not covered. The link below can be consulted for more advanced situations.
The instructions for changing the host name vary between versions of FreeBSD and Linux. The best thing to do is first check out whether they're already right. If they're right, in which case you need to go no further.
A bit of terminology first, let's say your fully qualified name (name for this specific machine) should be "mail.example.com".
Caution: some documents refer to the FQDN as the "hostname", and systems vary whether they return the FQDN or "short name" as the result of the "hostname" command.The following is a sequence of Ubuntu (all Debian-derived machines should be the same) commands you should execute, and their expected results (substituting mail.example.com etc with the values you want for your machine):
shell prompt> hostname -s mail shell prompt> hostname -d example.com shell prompt> hostname -f mail.example.com
Another thing to quickly check is the /etc/hosts file. The /etc/hosts file will generally look something like this (using "mail.example.com" as the name of the machine, and 18.104.22.168 as its IP address):
127.0.0.1 localhost 22.214.171.124 mail.example.com mail
If your machine does IPv6 too, you should see another pair of lines like this, where "<ipv6 address>" is the IPv6 address for your machine:
::1 localhost localhost.localdomain <ipv6 address> mail.example.com mail
The "localhost" definitions must be in front of the real IP addresses, and in no case should the localhost entries include "mail" or "mail.example.com".
If the results you obtain from the above commands is what you're expecting, breath a sigh of relief, you're done with this page
Seeing localhost or localhost.localdomain or a name without dots (except where we explicitly say they should be) are clear signs of wrongness.
If the results are wrong, there's a number of things you may need to change,
depending on what version of Linux/FreeBSD you are running.
We recommend doing a web search for "setting hostname