I currently am trying to connect to an external SMTP server so that I can send emails from a WP install using the WP Mail SMTP plugin. I’m not sure this is an issue from the hosting side here at DigitalOcean or from my email host but I’ve reached out to them and they said everything looks fine so I’m checking from this side.

Basically, I get the following debug output:

Connection: opening to ssl://mail.mysite.com:465, timeout=300, options=array ()

Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://mail.mysite.com:465 (Connection refused) [/var/www/html/wp-includes/class-smtp.php line 298]

SMTP ERROR: Failed to connect to server: Connection refused (111)

During my testing I tried to run a Netcat from the DigitalOcean Droplet and get:

nc: connect to mail.mysite.com port 465 (tcp) failed: Connection refused

However, if I run it from my local machine I get:

Connection to mail.mysite.com 465 port [tcp/urd] succeeded!

So that lead me to think maybe I do have an issue from the DigitalOcean side? I’m not sure but any guidance would be greatly appreciated.

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.

×
1 answer

Hi @theshowportal,

It does seem like you haven’t allow outgoing and incoming connections on port 465. You can do that by typing in the following rule on your droplet

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

Alternatively, I’ll recommend you to check some third party mail providers which actually provide you with a way to use their SMTP on your droplet. As they are made for such things as sending out emails and everything by default you shouldn’t have any issues with the mails. It would just be a matter of configuring your WP app.

Regards,
KFSys

  • Hi @KFSys,

    Thank you for that. I got word from support that they have blocked SMTP ports for spam protection and they couldn’t remove them for me.

    So I did like you suggested as an alternative and hooked up the WP app to an outside mail provider, MailGun. Thank you for that suggestion, was easy to do and seems to be working well.

    Best regards,
    Jake - theshowportal

Submit an Answer