[SOLVED] Nextcloud cannot connect to SMTP server known to be running: how to fix?

Nextcloud version (eg, 20.0.5): 21.0.0
Operating system and version (eg, Ubuntu 20.04): Debian 10 (via Linode Marketplace app)
Apache or nginx version (eg, Apache 2.4.25): Apache, version don’t know.
PHP version (eg, 7.4): PHP, version don’t know.

The issue you are facing:
Error message on Nextcloud admin pages to configure an SMTP connection, triggered by the “send email” testing button:

“A problem occurred when sending the email. Please revise your settings. (Error: Connection could not be established with the host mail.privateemail.com :stream_sock_client(): unable to connection to tcp://mail.privateemail.com:587 (Connection timed out)).”

The mail server’s instructions are here: https://www.namecheap.com/support/knowledgebase/article.aspx/1179/2175/general-private-email-configuration-for-mail-clients-and-mobile-devices/

Screenshot of error message here: https://drive.google.com/open?id=1v8vvuR0eB-8KaM7s-mil4U5-6kopxCa-

Screenshot of server’s firewall here: https://drive.google.com/open?id=1wtSHo8_MPKzlK3RR4Ejrc0sBvDZKmb-s

Is this the first time you’ve seen this error? (Y/N): Yes.

The output of your Nextcloud log in Admin > Logging: no entries relate to this issue.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!): don’t understand what this means.

The output of your Apache/nginx/system log in /var/log/____: not relevant.

I’d be grateful for assistance for any fixes or further diagnosis.

Turns out that the host had its own firewall, to block SMTP ports and protocols. An anti-spam measure.

Case closed.

2 Likes

I am having the same problem hosting on Linode. Any insight to the resolution would be amazing :slight_smile:

I looked in my linode firewall and dont have any firewalls setup

The following Linode Blog entry states Linodes on newly created customer accounts will have outbound connections from ports 25, 465, and 587 restricted by default.

https://www.linode.com/blog/linode/a-new-policy-to-help-fight-spam/

The following instructions resolve the issue.

  1. Configure valid A records and reverse DNS for the Linodes you’d like to use for mailing.
  2. Open a Support ticket and provide us with some basic information (the information we’ll ask for is outlined in our “Running a Mail Server” guide.)

Same !

After testing my server with telnet mail.xxx.net 465, i discover that it was not my server (with ufw) that was the cause of this issue, but Scaleway (where i rent my server) that disable SMTP
See their doc : How to enable SMTP for Elastic Metal servers