icon-dark icon-light

Php Send Mail

Php Send Mail

After installing sendmail on ubuntu server 14.04 / 16.04 , I tried sending mail from my php script and it was painfully slow. I thought I had not configured my apache / nginx properly. Me being a noob at this, tried to delete the snapshot and reinstalled with ubuntu 14.04 (earlier one being ubuntu 16). Still the issue persisted. After a lot of googling I kind of figured a solution.

Initially determine the hostname of your server by typing


This will reveal your hostname.

Then go to /etc/hosts

sudo vi /etc/hosts

Modify the line with IP to read as    localhost localhost.localdomain ashwin

(where “ashwin” is my server’s hostname, you should add your server’s hostname — duh!)

Finally I ran

sudo sendmailconfig

Answer Y to all the questions asked to rebuild/reload sendmail configuration…

That’s it, Send Mail started working !

Hope this helps for people who struggled with installing a new server in Digital Ocean / AWS and trying to send mail!