Configuring Sendmail on Ubuntu 14.04

If your PHP mail() function is slow or failing, it's probably because sendmail isn't installed on your server. Here's how you can fix it.

Install sendmail:

sudo apt-get install sendmail

Update your hosts file:

sudo vim /etc/hosts

You probably have something like this at the top: yourhost yourhost localhost

Change the second line to look like this, where yourhost is the same as whatever is in the line above it. localhost localhost.localdomain yourhost

Save the file and then run the sendmail config:

sudo sendmailconfig

Finally, enable Apache:

sudo service apache2 restart

Congrats! Sendmail is now installed and configured, and your PHP mail() function will send mail quickly now.

Author avatar

About the author

Creator of Surreal CMS and other web things. Follow me for tweets about JavaScript, CSS, and web programming.