30

When trying to start sendmail or send a mail using a wordpress plugin, this error shows up in the maillog:

"My unqualified host name (foo.bar) unknown; sleeping for retry"

After Googling the best advice was, "add foo.bar to the /etc/hosts file", but it already is:

127.0.0.1     localhost localhost.localdomain
127.0.0.1     foo.bar
49

Simply changed:

127.0.0.1     localhost localhost.localdomain
127.0.0.1     foo.bar

To this

127.0.0.1     localhost localhost.localdomain foo.bar

Sendmail looks for a fully qualified domain (FQDN) name and will use the localhost.localdomain in the single line version.

  • 1
    fixed my problem. Just want to be clear, it is the hostname that should be put in this line. So first use hostname command find it, than add it to this line in \etc\hosts . Thanks, man. – leon Jul 4 '13 at 6:53
  • It didn't work for me – user10089632 Mar 13 '18 at 19:12
  • or actually use a domain name that exists and is configured properly. At least if you want your mail to get delivered you should. – Sammitch Dec 29 '18 at 1:41
0

Simply adding the domain to your hosts files as @rjstelling suggests will only allow your mail to be sent, but it is incredibly unlikely to land in someone's inbox.

In order to send an email that won't be flagged as spam, to say nothing of the receiving server just terminating the delivery attempt or dropping the message, you need to be using a real, registered domain name with working DNS and an MX record.

And that is to say nothing for FCRDNS or any one of the dozens of things that you need to do to run a server whose email might actually be accepted most of the time. [if the internet gods deign to smile upon you even briefly] The true answer is that you probably shouldn't be running your own mailserver because it's simply not worth the work required to keep it in good standing. Look into mail services like SendGrid, MailChimp, etc.

0

The accepted answer:

    127.0.0.1   localhost localhost.localdomain foo.bar

seems to work, but produces the errors in /var/log/syslog:

    sendmail[11655]: gethostbyaddr(192.168.1.123) failed: 1

But leaving just

    127.0.0.1   localhost

in /etc/hosts, and removing the second line allows mail to get sent, and does not result in any errors.

Update: when doing sudo ...whatever.. there is a message sudo: unable to resolve host foo.bar, but looks like it does not affect anything..

BTW, to restart the hostname service without reboot:

    systemctl restart systemd-hostnamed

On Ubuntu 16.04, but should not be necessary for mail to work after editing /etc/hosts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.