How to make WordPress droplet send emails?

Posted August 4, 2019 6.2k views
WordPressUbuntu 18.04

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?

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.

Submit an Answer
3 answers


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 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.

  • Connection to 25 port [tcp/smtp] succeeded!

    • Thanks for confirming this.

      Do you receive any error messages? How exactly you’re testing the mail functionality?

      Looking forward to your reply.


      • No error messages.

        I test the mail functionality using the following URL in WordPress Admin:


        It says:

        “We have just sent an e-mail using wp_mail() and it seems to work. Please check your inbox and spam folder to see if you received it.”

        But I never receive any emails at all.

  • Hello, I tried this. I am getting the following error:
    “`Connection timed out
    Network is unreachable

In case anyone else gets here via Google, you have to install sendmail:

apt-get install sendmail 

Test it by running:

echo "email body" > mail.txt
echo "Subject: hello" | sendmail -v < mail.txt

^change “” 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…

  • Just following up on this as I finally got it working. It was the SPF the whole time.

    Instead of v=spf1 ~all

    I had to specify the originating IP address:

    v=spf1 ip4:999.999.999.999 ~all

    Of course replace the “999.999.999.999” with your droplet’s IP address. I had to wait overnight for this to fully propagate but now Wordpress is successfully sending emails to Gmail without getting bounced. It’s going to the spam folder but at least I can change my password and do other administrative tasks.

    More reading:

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!