gen-smtp / gen_smtp

The extensible Erlang SMTP client and server library.
Other
683 stars 266 forks source link

:gen_smtp_client.send_blocking always returns {:error, :retries_exceeded, {:network_failure, <IP>, {:error, :timeout}}} #300

Closed messutied closed 3 years ago

messutied commented 3 years ago

Hi there,

I'm having issues when attempting to send emails with :gen_smtp_client.send_blocking, I'm trying from a Heroku dyno, what's strange is that it works on one dyno and in another no, the only difference is once has Heroku 18 the other has 20 (Ubuntu 20.04) which is where is failing, so I suspect it has to do with that.

The logs I'm getting are:

MX records for smtp.eu.mailgun.org are [{10,"35.156.190.149"},
                                        {10,"35.157.140.183"},
                                        {10,"3.122.29.183"}]
scheduling 35.156.190.149 for retry (1 of 1)
scheduling 35.157.140.183 for retry (1 of 1)
scheduling 3.122.29.183 for retry (1 of 1)
retries for 35.156.190.149 exceeded (1 of 1)
retries for 35.157.140.183 exceeded (1 of 1)
retries for 3.122.29.183 exceeded (1 of 1)
{:error, :retries_exceeded,
 {:network_failure, '3.122.29.183', {:error, :timeout}}}

So as you can see, it doesn't reach the step "connected to 35.157.140.183; banner was Mailgun Influx ready", which it can reach on the dyno with 18 stack.

I'm using gen_smtp 1.1.1, from Elixir 1.11.2 and erlang 23.3.4, I upgraded just to ensure it's not something solved on a newer version.

Any advice will be highly appreciated!

messutied commented 3 years ago

I've found the root of the issue, and is unrelated to gen_smtp so I'm closing this issue.

For anybody else that might encounter this problem, for some reason some SMTP servers will timeout if you connect to them on port 25, depending on your region, in that case using port 587 or 2525 instead is the solution (source).