By plotfish
My WordPress droplet on Ubuntu 18.04 cannot send emails via wp_mail() function.
I want my WordPress droplet to send emails via wp_mail() function, not an external SMTP plugin.
How to I fix this problem?
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!
Hello,
Could you please let me know if you’re receiving any error messages? Can you please post the output of this command? It will check if your Droplet is able to communicate over the ports required to send emails externally:
nc -vz smtp.gmail.com 25
Some accounts have SMTP blocked default due to abuse and the output will help us to see if you’re having this issue.
Looking forward to your reply.
In case anyone else gets here via Google, you have to install sendmail:
https://www.postmm.com/web-development/how-to-set-up-wordpress-on-digital-ocean/
apt-get install sendmail
Test it by running:
echo "email body" > mail.txt
echo "Subject: hello" | sendmail -v RECIPIENT@gmail.com < mail.txt
^change “RECIPIENT@gmail.com” to your email address for testing.
While it’s sending check the status messages. The Google server may block the email from going through because it thinks it’s spam. Going through the fun process of setting up SPF and DKIM now…
Hello all,
What I could suggest here is using an SMTP plugin for your WordPress site.
That way you will be able to specify an SMTP server with authentication which your emails would be going through. You could for example use Gmail’s SMTP settings. This would drastically increase the delivery rate of your emails as well compared to using plain PHP mail.
I’ve been using this plugin for a while now and it works very well: Easy WP SMTP
Hope that this helps! Regards, Alex
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.