Wordpress not sending emails on a certain site (Apache Virtual Hosts) Ubuntu 16.04

Posted September 10, 2020 926 views
ApacheWordPressEmailUbuntu 16.04

I have three Wordpress sites on this droplet. The first two send emails fine. The third one, which I have set up recently, will not send emails - not from contact us forms, nor from trying to change the admin email. The forms etc appear to work fine but no email ever shows up.

I am using Migadu. Sending emails manually from this domain is fine. So I don’t think it’s the DNS.

Nothing shows up in /var/log/mail.log. In fact this file has not been edited since 2018. Same for mail.log.1

I tried using WP Mail SMTP plugin and pointing it at Migadu SMTP. This doesn’t work, it says “There was a problem while sending the test email” when testing.

I never had this problem when I set up the second Virtual Host site. What could be causing this?

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
2 answers

Hi @umpire,

You’ve been on the right track, the best way to make sure your e-mails will be received is using a plugin for SMTP, like in your case WP MAIL SMTP.

Yes, you mentioned you received the error “There was a problem while sending the test email” however this I believe is because of the port you’ve used to be set as closed. So, I believe you’ve either used port 465 or 587 to send the e-mails, correct? Either of these should be allowed for outgoing connections in order for you to be able to send out e-mails using Migadu.

You can allow either port with the following two commands

sudo iptables -A OUTPUT -p tcp --dport 465 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A INPUT -p tcp --sport 465 -m conntrack --ctstate ESTABLISHED -j ACCEPT

Or for port 587

sudo iptables -A OUTPUT -p tcp --dport 587 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A INPUT -p tcp --sport 587 -m conntrack --ctstate ESTABLISHED -j ACCEPT


  • Hi @KFSys

    You’re 100% right, it’s the port. I used a plugin (WP Mail SMTP) to fix it (specifying Migadu SMTP with the 587 port).

    Would your method help me to do this without the need for a plugin?

    And do you have any idea why my other sites on this droplet are working fine? Same mail setup with Migadu/Wordpress but no need for the plugin.


    • I would recommend using the Plugin otherwise your website will use the normal PHP mail function which is considered by many as a spam tool rather than a legitimate one.

      As for your second question, I can’t really tell you here, it might need further troubleshooting to understand why the other two websites are sending out mails.