Ubuntu 16 + Wordpress + WP Mail SMTP + PHP Applications on server can't connect to SendGrid or Other SMTP Relay

Hi, I’m new to server management. I’ve installed LAMP stack and setup Wordpress on main domain and a PHP script on sub domain… After it I want SendGrid SMTP to be used by Wordpress web and by script, I do it on Wordpress by WP Mail SMTP plugin and setup SendGrid API in it and click save when I go to check this out, I go to wordpress login page then forgot password and type my email in it and hit enter but it gives me error PHP mail() function is disabled on my server! After it I open WP Mail SMTP and change the settings from SendGrid to None (System Defaults) and click save, now i again go to check this by going to forgot password entered my email and press enter, Email send successfully! On my email I’ve received password reset email by root@localhost, Same error with other PHP script on which in script SMTP settings i put all SendGrid SMTP values and click save but it gives me “Connection Failed” error! Please help me :')

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This comment has been deleted

You may need to install the sendmail or postfix package on your droplet in order for the PHP mail() function to be able to attempt to send via SMTP.

sudo apt-get update;
sudo apt-get install postfix;