Sendmail very slow - /etc/hosts configuration

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

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