# Não é possível enviar e-mail: Net::ReadTimeout

**URL:** https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419
**Category:** Self-hosting
**Created:** [30 Setembro , 2018 18:06 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419 "2018-09-30T18:06:12Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [30 Setembro , 2018 18:06 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/1 "2018-09-30T18:06:12Z")

</div>

I installed discourse behind nginx according [this post](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247). 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:

```plaintext
- "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

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [30 Setembro , 2018 18:48 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/2 "2018-09-30T18:48:31Z")

</div>

Try using port 2525.

---

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [30 Setembro , 2018 20:08 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/3 "2018-09-30T20:08:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [30 Setembro , 2018 20:51 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/4 "2018-09-30T20:51:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [30 Setembro , 2018 20:59 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/5 "2018-09-30T20:59:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [30 Setembro , 2018 21:01 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/6 "2018-09-30T21:01:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [30 Setembro , 2018 21:07 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/7 "2018-09-30T21:07:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [30 Setembro , 2018 21:11 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/8 "2018-09-30T21:11:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [30 Setembro , 2018 21:42 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/9 "2018-09-30T21:42:05Z")

</div>

Try from inside the container.

```
./launcher enter app 

```

You may have docker blocked from getting outside.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [30 Setembro , 2018 21:49 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/10 "2018-09-30T21:49:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [1 Outubro , 2018 06:17 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/11 "2018-10-01T06:17:44Z")

</div>

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#

```

---

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [1 Outubro , 2018 19:30 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/12 "2018-10-01T19:30:29Z")

</div>

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"=&gt;"signup", "user_id"=&gt;1, "email_token"=&gt;"...", "current_site_id"=&gt;"default"} Jobs::HandledExceptionWrapper: Wrapped ArgumentError: wrong authentication type none`

---

<div class="post-metadata">

### Author: ![webmayak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/webmayak/32/132843_2.png) [@webmayak](https://meta.discourse.org/u/webmayak)
#### Post date: [3 Março , 2019 14:36 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/13 "2019-03-03T14:36:10Z")

</div>

@acinonyxjubatus did you find a solution? I have the same problem with [smtp.yandex.ru](http://smtp.yandex.ru) on DigitalOcean one-click Discourse app..

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [3 Março , 2019 19:14 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/14 "2019-03-03T19:14:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![acinonyxjubatus](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@acinonyxjubatus](https://meta.discourse.org/u/acinonyxjubatus)
#### Post date: [3 Março , 2019 19:32 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/15 "2019-03-03T19:32:30Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![webmayak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/webmayak/32/132843_2.png) [@webmayak](https://meta.discourse.org/u/webmayak)
#### Post date: [12 Março , 2019 03:54 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/16 "2019-03-12T03:54:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sidor1989](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sidor1989/32/176896_2.png) [@sidor1989](https://meta.discourse.org/u/sidor1989)
#### Post date: [14 Abril , 2020 20:56 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/17 "2020-04-14T20:56:18Z")

</div>

Alguém encontrou uma solução? O Yandex não funciona com as portas 465 e 567. Mas o curl funciona corretamente.

```
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#

```

Qual poderia ser o motivo?  
Yandex e Discourse são incompatíveis?

---

<div class="post-metadata">

### Author: ![Stranik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stranik/32/85638_2.png) [@Stranik](https://meta.discourse.org/u/Stranik)
#### Post date: [28 Abril , 2020 10:48 UTC](https://meta.discourse.org/t/not-able-to-send-email-net-readtimeout/98419/18 "2020-04-28T10:48:44Z")

</div>

> [@sidor1989](#):
>
> portas 465 e 567.

**587**!

Usamos vários sites Discourse com o Yandex. E em todos eles, com a porta **587** , funciona perfeitamente. A porta 465 não funcionou inicialmente.
