# SMTP Net::ReadTimeout without relation to net or login problems - SMTP host is just slow

**URL:** <https://meta.discourse.org/t/smtp-net-readtimeout-without-relation-to-net-or-login-problems-smtp-host-is-just-slow/235727>\
**Category:** Feature\
**Tags:** completed\
**Created:** [August 10, 2022, 12:42pm UTC](https://meta.discourse.org/t/smtp-net-readtimeout-without-relation-to-net-or-login-problems-smtp-host-is-just-slow/235727 "2022-08-10T12:42:27Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![rfk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rfk/32/270287_2.png) [@rfk](https://meta.discourse.org/u/rfk)\
**Post date:** [August 10, 2022, 12:42pm UTC](https://meta.discourse.org/t/smtp-net-readtimeout-without-relation-to-net-or-login-problems-smtp-host-is-just-slow/235727/1 "2022-08-10T12:42:27Z")

</div>

Hello,

since view weeks sending mail from my Discourse instance fails. The SMTP settings are unchanged, curl test is still working but notably slow. The smtp server from our hoster (that we need to send mails with) has a consistent send time of 7 seconds.

```plaintext
cat testmail | curl -vvv --url 'smtp://smtp.<HOST>:587' --mail-from mail@<DOMAIN> --mail-rcpt <ME> --user "mail@<DOMAIN>:<PW>" -T -

  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying <IP>...
* Connected to smtp.<HOST> (<IP>) port 587 (#0)
< 220 mailproxy1.<HOST> Dovecot ready.
> EHLO ecm2
< 250-mailproxy1.<HOST>
< 250-8BITMIME
< 250-AUTH PLAIN LOGIN
< 250-BURL imap
< 250-ENHANCEDSTATUSCODES
< 250-SIZE
< 250-STARTTLS
< 250 PIPELINING
> AUTH PLAIN
< 334 
> xxxxxx=
  0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0< 235 2.7.0 Authentication successful
  0 0 0 0 0 0 0 0 --:--:-- 0:00:07 --:--:-- 0> MAIL FROM:<mail@<DOMAIN>>
< 250 2.1.0 Ok
> RCPT TO:<<ME>>
< 250 2.1.5 Ok
> DATA
< 354 End data with <CR><LF>.<CR><LF>
} [89 bytes data]
100 89 0 0 0 89 0 11 --:--:-- 0:00:07 --:--:-- 20< 250 2.0.0 Ok: queued as 356C3288C85
100 89 0 0 0 89 0 11 --:--:-- 0:00:07 --:--:-- 26
* Connection #0 to host smtp.<HOST> left intact

```

I compared this to our internal mail server with \<1 second per mail. The 7 seconds from the mail hoster would be no real problem, but I was unable to identify a setting where to lift the (seemingly hard-coded?) 5 seconds timeout. The `open_timeout` and, as it seems to me, more relevant `read_timeout` is also visible in the test interface at `/admin/email`:

 ![screenshots](https://global.discourse-cdn.com/meta/original/4X/c/e/4/ce481b61e018ca89758b2bf03cc8b793970dfaf2.png)

- Timings in the docker app container is identical to a local test or a test on the docker host.
- cURL sent mails are delivered correctly (after the 7 seconds wait + the blink of an eye).
- For privacy reasons, the usual workarounds like sendgrid, mailgun etc. are sadly no option.
- Maybe a switch to `ActionMailer` 7.0.x triggerd this problem for me?
  - [rails/actionmailer/CHANGELOG.md at v7.0.3.1 · rails/rails · GitHub](https://github.com/rails/rails/blob/v7.0.3.1/actionmailer/CHANGELOG.md)
  - 

> Configures a default of 5 for both `open_timeout` and `read_timeout` for SMTP Settings.

Thank you for any idea how to configure `read_timeout`.

---

_[View the full topic](https://meta.discourse.org/t/smtp-net-readtimeout-without-relation-to-net-or-login-problems-smtp-host-is-just-slow/235727)._
