Not able to send email Net::ReadTimeout

I installed discourse behind nginx according this post. Also I have SSL certificate installed by certboot
Registration activation email is not sending and when I run ./discourse-doctor on email sending step I get
Net::ReadTimeout

However, everything is OK with curl. I send message on the same port (465) and receive message.
My settings are:

- "templates/web.socketed.template.yml"
  DISCOURSE_SMTP_ADDRESS: smtp.yandex.ru
  DISCOURSE_SMTP_PORT: 465
  DISCOURSE_SMTP_USER_NAME: _name_
  DISCOURSE_SMTP_PASSWORD: _pass_
  DISCOURSE_SMTP_ENABLE_START_TLS: true

Try using port 2525.

No success. Got this
======================================== ERROR ========================================

Connection to port 2525 failed.

====================================== SOLUTION =======================================

The most likely problem is that your server has outgoing SMTP traffic blocked.

If you are using a service like Mailgun or Sendgrid, try using port 2525.

update: curl also fails on 2525

Are you on DigitalOcean? They are known to block outbound mail ports on new servers, particularly on new accounts.

Reach out to them to get it unblocked if so, but use 587 if possible! 465 was revoked by the IETF years ago.

Not DigitalOcean. I use other Ubuntu VPS and Yandex as smtp server.
Curl fails on 25, 2525 and 587 ports, but works on 465

Either way sounds like your provider is blocking you. Definitely worth reaching out to get the restriction removed.

1 Like

I am able to connect to smtp server via telnet on ports 25, 587 and 465. So, I don’t think someone blocks ports.

The Question is why am I getting ReadTimeout with Discourse while with curl I can successfully send message (on 465 port)

Try from inside the container.

./launcher enter app 

You may have docker blocked from getting outside.

1 Like

Or whichever host is conducting traffic inspection, which would explain why it works until you wrap it in TLS.

1 Like

Tried from within docker. Successfully sent with curl

root@server-app:/var/www/discourse# curl --url 'smtps://smtp.yandex.ru:465' --ssl-reqd \
   --mail-from '...' --mail-rcpt '...' \
   --upload-file mail1.txt --user 'login:pass'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   167    0     0  100   167      0    166  0:00:01  0:00:01 --:--:--   167
root@server-app:/var/www/discourse#
1 Like

What else can I try to make it work?

I checked logs and found nothing interesting
In production.log:

   Started PUT "/finish-installation/resend-email" for ip at 2018-10-01 19:22:45 +0000
Processing by FinishInstallationController#resend_email as HTML
  Parameters: {"authenticity_token"=>"..."}
  Rendering finish_installation/resend_email.html.erb within layouts/finish_installation
  Rendered finish_installation/resend_email.html.erb within layouts/finish_installation (0.8ms)
  Rendered common/_special_font_face.html.erb (0.2ms)
  Rendered layouts/_head.html.erb (0.3ms)
Completed 200 OK in 23ms (Views: 2.5ms | ActiveRecord: 3.6ms)

update
I manually activated account with

rake admin:create

and in sidekiq section I see this:

{"type"=>"signup", "user_id"=>1, "email_token"=>"...", "current_site_id"=>"default"} Jobs::HandledExceptionWrapper: Wrapped ArgumentError: wrong authentication type none

@acinonyxjubatus did you find a solution? I have the same problem with smtp.yandex.ru on DigitalOcean one-click Discourse app…

First I’d try using port 2525 (mailgun and others accept mail at that port). If that does not work, open a ticket with digital ocean to have them remove the block from the port.

Looks like Yandex blocks and/or delays emails or maybe Discourse works good only with Mailgun. After days of struggling I gave up and switched to mailgun and letsencrypt with this settings:

  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"
...
expose:
  - "80:80"   # http
  - "443:443" # https
...
  DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
  DISCOURSE_SMTP_PORT: 587

Good luck!

2 Likes

@acinonyxjubatus, thanks for your reply! With Mailgun Discourse really works “from scratch”… It solved the problem with outgoing mail for now. Thanks!

2 Likes

Has anyone found a solution? Yandex does not work with ports 465 and 567. But does the curl work correctly.

root@server-app:/var/www/discourse# curl --url 'smtps://smtp.yandex.ru:465' --ssl-reqd \
--mail-from '...' --mail-rcpt '...' \
--upload-file mail1.txt --user 'login:pass'
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                               Dload  Upload   Total   Spent    Left  Speed
100   167    0     0  100   167      0    166  0:00:01  0:00:01 --:--:--   167
root@server-app:/var/www/discourse#

What could be the reason?
Yandex and Discourse are incompatible?

587!

We use several Discourse sites with Yandex. And everywhere with port 587 it works great. Port 465 did not work initially.

1 Like