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.
sudo apt-get install sendmail
Update your hosts file:
sudo vim /etc/hosts
You probably have something like this at the top:
127.0.1.1 yourhost yourhost
Change the second line to look like this, where yourhost is the same as whatever is in the line above it.
127.0.0.1 localhost localhost.localdomain yourhost
Save the file and then run the sendmail config:
Finally, enable Apache:
sudo service apache2 restart
Congrats! Sendmail is now installed and configured, and your PHP
mail() function will send mail quickly now.