Loomio
Mon 27 Mar 2017 5:47PM

Loomio won't send any emails

PC Pablo Costa Public Seen by 48

I have verified the SMTP settings are OK, to the point of chatting by hand with the SMTP server with openssl s_client from the docker container loomiodeploy_loomio_1, and successfully authenticating.

Debugging the "reset password" use case, the attempt to send the email ends with Net::ReadTimeout:

loomio_1 | Started POST "/users/password" for 11.22.33.44 at 2017-03-27 17:12:34 +0000
loomio_1 | Processing by Devise::PasswordsController#create as HTML
loomio_1 |   Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"[email protected]"}, "commit"=>"Send me reset password instructions"}
loomio_1 |   Rendered devise/mailer/reset_password_instructions.html.haml within layouts/base_mailer (165.5ms)
loomio_1 |   Rendered devise/mailer/reset_password_instructions.text.haml within layouts/base_mailer (18.6ms)
loomio_1 |
loomio_1 | Sent mail to [email protected] (60123.6ms)
loomio_1 | Completed 500 Internal Server Error in 63519ms (ActiveRecord: 656.2ms)
loomio_1 | 
loomio_1 | Net::ReadTimeout (Net::ReadTimeout):
loomio_1 |   app/models/user.rb:274:in `block in send_devise_notification'
loomio_1 |   app/models/user.rb:274:in `send_devise_notification'

For testing, I appended some garbage to the SMTP server name, just to be sure that these logs are talking about my SMTP server; I get SocketError (getaddrinfo: Name or service not known):

loomio_1 | Sent mail to [email protected] (338.4ms)
loomio_1 | Completed 500 Internal Server Error in 4933ms (ActiveRecord: 833.2ms)
loomio_1 | 
loomio_1 | SocketError (getaddrinfo: Name or service not known):
loomio_1 |   app/models/user.rb:274:in `block in send_devise_notification'
loomio_1 |   app/models/user.rb:274:in `send_devise_notification'

I also tried with a wrong port, and then the error is Net::OpenTimeout ('connection refused', I guess):

loomio_1 | Sent mail to [email protected] (30059.1ms)
loomio_1 | Completed 500 Internal Server Error in 33509ms (ActiveRecord: 516.3ms)
loomio_1 | 
loomio_1 | Net::OpenTimeout (execution expired):
loomio_1 |   app/models/user.rb:274:in `block in send_devise_notification'
loomio_1 |   app/models/user.rb:274:in `send_devise_notification'

Can someone provide some advice about how to debug this issue?

PC

Pablo Costa Mon 27 Mar 2017 7:05PM

The docker container loomiodeploy_worker_1 is also unable to send emails:

worker_1 | Sent mail to [email protected] (60189.7ms)
worker_1 | [Worker(host:07479e734491 pid:1)] Job ThreadMailer.send (id=315) FAILED (4 prior attempts) with Net::ReadTimeout: Net::ReadTimeout
worker_1 | 2017-03-27T18:58:28+0000: [Worker(host:07479e734491 pid:1)] Job ThreadMailer.send (id=315) FAILED (4 prior attempts) with Net::ReadTimeout: Net::ReadTimeout
RG

Robert Guthrie Mon 27 Mar 2017 9:06PM

Hrrmm.. troubling!

Are you able to view your SMTP logs and see what your SMTP server is saying?

PC

Pablo Costa Wed 29 Mar 2017 7:38PM

I'm afraid the SMTP server is not mine (it's Gandi's).

I tried also with my ISP's SMTP server, same result.

It's strange enough because I can chat with the SMTP server from inside the docker container:

$ docker exec -ti loomiodeploy_worker_1 openssl s_client -connect mail.gandi.net:465

I am thinking of setting up my own SMTP server but I find it really strange that my "manual chat" results in an actual conversation with the server, even before I type anything like the EHLO:

# tcpdump -ni eth0 host mail.gandi.net
17:44:28.032446 IP 10.10.10.10.39267 > 217.70.184.11.465: Flags [S], seq 1515668828, win 29200, options [mss 1460,sackOK,TS val 69874319 ecr 0,nop,wscale 7], length 0
17:44:28.074806 IP 217.70.184.11.465 > 10.10.10.10.39267: Flags [S.], seq 4026541474, ack 1515668829, win 28960, options [mss 1460,sackOK,TS val 2170715856 ecr 69874319,nop,wscale 7], length 0
17:44:28.074899 IP 10.10.10.10.39267 > 217.70.184.11.465: Flags [.], ack 1, win 229, options [nop,nop,TS val 69874329 ecr 2170715856], length 0
17:44:28.075756 IP 10.10.10.10.39267 > 217.70.184.11.465: Flags [P.], seq 1:290, ack 1, win 229, options [nop,nop,TS val 69874329 ecr 2170715856], length 289
17:44:28.117923 IP 217.70.184.11.465 > 10.10.10.10.39267: Flags [.], ack 290, win 235, options [nop,nop,TS val 2170715867 ecr 69874329], length 0
17:44:28.118824 IP 217.70.184.11.465 > 10.10.10.10.39267: Flags [.], seq 1:1449, ack 290, win 235, options [nop,nop,TS val 2170715867 ecr 69874329], length 1448
[...]

while Loomio's attempt to deliver emails seems to cause the SMTP server to sever the connection:

# tcpdump -ni eth0 host mail.gandi.net
17:52:56.364247 IP 10.10.10.10.57596 > 217.70.184.11.465: Flags [S], seq 3268448418, win 29200, options [mss 1460,sackOK,TS val 70001401 ecr 0,nop,wscale 7], length 0
17:52:56.416927 IP 217.70.184.11.465 > 10.10.10.10.57596: Flags [S.], seq 775681834, ack 3268448419, win 28960, options [mss 1460,sackOK,TS val 2125001772 ecr 70001401,nop,wscale 7], length 0
17:52:56.417011 IP 10.10.10.10.57596 > 217.70.184.11.465: Flags [.], ack 1, win 229, options [nop,nop,TS val 70001415 ecr 2125001772], length 0

I am running tcpdump in the host, not inside any docker container.

RG

Robert Guthrie Thu 30 Mar 2017 6:25PM

I'm sorry but I'm unable to provide this level of support, I just don't have time.

We/Loomio did not write any of the SMTP code, this is all standard Rails libraries. The only thing we do is pass in configuration options.

In my experience SMTP servers are quite picky about the settings being correct, PORT, AUTH, SSL/TLS etc and you need to be confident you have those things correct.

I have created an SMTP docker image: https://github.com/robguthrie/haraka-relay
You might find that useful if you decide to setup your own SMTP.

Good luck, but I think you might need to ask for support somewhere if you don't find what you need here.

JS

Joel Stevens Wed 7 Jun 2017 2:49PM

Hi Robert,

I have a bit of the same issue, so I installed the Haraka image like you describe.

However, I am getting this error:
[Worker(host:162f9a0c2782 pid:1)] Job UserMailer.login (id=434) FAILED (3 prior attempts) with Net::SMTPAuthenticationError: 500 Unrecognized command

I am thinking this might be an SSL/TLS issue as Haraka does not allow auth commands until STARTTLS happens.

But I am confused because Loomio creates its own letsencrypt certificate for my site.
Do I need to replace Haraka's tls_key.pem and tls_cert.pem with ones from Loomio? Do you know where I can find these files?

Best,
Joel

RG

Robert Guthrie Wed 7 Jun 2017 8:22PM

Hi Joel, we're trying to release a new frontpage (and new features) today, I'm swamped, and just don't have time to look into this right now.

I would guess it's your auth username/password rather than SSL problems.

Good luck.