It takes ~15 seconds to send single e-mail using sendmail.


Jul 31 09:52:42 piotr-probook sendmail[2912]: My unqualified host name (piotr-probook) unknown; sleeping for retry



/etc/hosts:   piotr-probook localdev localhost router


# hosts file (normally /etc/hosts)
O HostsFile=/etc/hosts

Obviously I can ping piotr-probook host and HTTP server popups in browser when i type url http://piotr-probook

What am I doing wrong? How to fix the problem?

  • Your question and Problem is unclear. Please add more information about what you're trying to archive and what your Problems are (e.g. How do you use sendmail? In a PHP script? Python? Java? Is Apache involved?). Basically: What are you doing? – mondjunge Jul 31 '13 at 9:20
  • @mondjunge My problem is quite clear. It takes ~15 seconds to send single e-mail using sendmail. I even posted the cause of the issue (see log), and I am just asking how to fix it. I just want to execute sendmail -t mail.txt. No PHP, Java, etc. plain sendmail. – Piotr Jul 31 '13 at 9:55
  • 1
    Got the answer: – Piotr Jul 31 '13 at 10:22
  • Ok, what I am basically saying is, that your question could be improved to get more answers. It takes some thinking to get what you are doing and asking. It is better to start of with explaining what you are doing than jumping directly to your problem, but fair enough you found an answer by yourself, very good. – mondjunge Jul 31 '13 at 13:08
  • @mondjunge I am not new to Stack Overflow, check my another account. IMO I described situation very well: "I can't use sendmail, there is the cause, there is config file, what am I doing wrong?". There was nothing more to add. And I got perfect answer at :) – Piotr Jul 31 '13 at 13:50

The above answer didn't work for me. So I am posting here what I have done to make it work.

Installed send mail through terminal

apt-get install sendmail

then opened the hosts file

# edited from: sudo gedit etc/hosts
sudo gedit /etc/hosts

replaced the the line localhost

with localhost localhost.localdomain mydomainname

To get the domain name please type


in terminal and run.

restart apache

sudo service apache2 restart
  • 1
    sendmail should not be related to apache – Zitrax Jan 30 '15 at 14:54
  • @Zitrax i didn't get you. Can you please explain what do you mean? – Mad Angle Apr 2 '15 at 6:16
  • 1
    Your last step restarts apache, I just meant that shouldn't be needed for fixing the sendmail issue. – Zitrax Apr 2 '15 at 7:38
  • 1
    Very clear and worked like a charm. Thanks! – Andrew Swift Apr 30 '15 at 13:53
  • The apache restart ins't necessary I'm guessing, since you changed the hosts file and it is independent form apache. Anyway, I might be wrong and restarting apache also does something weird to sendmail, maybe it touches some files used by both Apache and Senmail but I doubt it. – loco.loop Sep 1 '16 at 19:13
up vote 13 down vote accepted

Got the answer at

Sendmail requires that the result of "hostname" be a fully qualified domain name to start cleanly.

Set the hostname to something like piotr-probook.localdomain and update /etc/hosts.

/etc/hosts   piotr-probook.localdomain piotr-probook localdev localhost
  • Also make sure you have a resolvable FQDN in /etc/mailname – jeremiah Aug 1 '13 at 8:08
  • in my case localhost.localdomain along with localhoat and hostname was the missing piece (debian's sendmail inside docker) – vladkras Jun 19 '17 at 9:36

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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