Loomio
Tue 29 Aug 2017 8:31PM

First time deploy - using GMAIL as SMTP (solved)

DU Jose Simoes Public Seen by 411

Hi there!

I've deployed Loomio on a DigitalOcean droplet. I got a subdomain to point to the server, and I eventually managed to build the whole thing. The dashboard shows up, but Loomio cannot send e-mails. More info on that:

I followed the deployment guide and everything else is running smoothly, except for e-mails.

I'm using gmail's SMTP. Created an account on gmail and just copied the account and auth details to the env file (smtp server: smtp.gmail.com, port 465, user, password).

My log ouput, regarding the mailing problem, on startup:
~~~~
mailin_1 | info: Mailin v3.0.3
letsencrypt_1 | Creating/renewal loomio.MY_DOMAIN.org certificates... (loomio.appning.org)
mailin_1 | info: Webhook url: http://loomio:3000/email_processor/
mailin_1 | info: Log file: /var/log/mailin.log
mailin_1 | info: Mailin Smtp server listening on port 25
mailin_1 | warn: Webhook http://loomio:3000/email_processor/ seems invalid or down. You may want to double check the webhook url.
(...)
worker_1 | [Worker(host:7d324c3af761 pid:1)] Starting job worker
worker_1 | 2017-08-29T20:24:12+0000: [Worker(host:7d324c3af761 pid:1)] Starting job worker
loomio_1 | [5] * Listening on tcp://0.0.0.0:3000
loomio_1 | [5] Use Ctrl-C to stop
loomio_1 | [5] - Worker 0 (pid: 7) booted, phase: 0
~~~~

My log output when I try to register:
~~~~
loomio_1 | Started POST "/api/v1/login_tokens" for X.X.X.X at 2017-08-29 20:27:12 +0000
loomio_1 | Processing by API::LoginTokensController#create as JSON
loomio_1 | Parameters: {"email"=>"[email protected]", "login_token"=>{}}
loomio_1 | Completed 200 OK in 295ms (ActiveRecord: 50.7ms)
nginx_1 | nginx.1 | loomio.MY_DOMAIN.org X.X.X.X - - [29/Aug/2017:20:27:13 +0000] "POST /api/v1/login_tokens HTTP/2.0" 200 25 "https://loomio.MY_DOMAIN.org/dashboard" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0"
worker_1 | [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) RUNNING
worker_1 | 2017-08-29T20:27:17+0000: [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) RUNNING
worker_1 | Rendered user_mailer/login.html.haml within layouts/invite_people_mailer (30.7ms)
worker_1 | Sent mail to [email protected] (10095.9ms)
worker_1 | [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) FAILED (0 prior attempts) with EOFError: end of file reached
worker_1 | 2017-08-29T20:27:31+0000: [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) FAILED (0 prior attempts) with EOFError: end of file reached
worker_1 | [Worker(host:7d324c3af761 pid:1)] 1 jobs processed at 0.0580 j/s, 1 failed
worker_1 | 2017-08-29T20:27:31+0000: [Worker(host:7d324c3af761 pid:1)] 1 jobs processed at 0.0580 j/s, 1 failed
worker_1 | [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) RUNNING
worker_1 | 2017-08-29T20:27:41+0000: [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) RUNNING
worker_1 | Rendered user_mailer/login.html.haml within layouts/invite_people_mailer (8.1ms)
worker_1 | Sent mail to [email protected] (10032.6ms)
worker_1 | [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) FAILED (1 prior attempts) with EOFError: end of file reached
worker_1 | 2017-08-29T20:27:51+0000: [Worker(host:7d324c3af761 pid:1)] Job UserMailer.login (id=31) FAILED (1 prior attempts) with EOFError: end of file reached
worker_1 | [Worker(host:7d324c3af761 pid:1)] 1 jobs processed at 0.0963 j/s, 1 failed
worker_1 | 2017-08-29T20:27:51+0000: [Worker(host:7d324c3af761 pid:1)] 1 jobs processed at 0.0963 j/s, 1 failed

~~~~

I don't know how to debug that "Job UserMailer.login (id=31) FAILED (1 prior attempts) with EOFError: end of file reached" log line.

Any insights/help? Thank you!

DU

Jose Simoes Fri 8 Sep 2017 1:52PM

Bump

RG

Robert Guthrie Sun 10 Sep 2017 10:03PM

Hi @josesimoes I don't know what the issue is exactly but it looks like your SMTP settings don't work.
I suggest you use another SMTP for this, maybe a free tier of another service, or setup your own SMTP server.

I have not used gmail for this in a long time and I don't know if it still works. Maybe someone else in here can let us know if they are successfully using gmail.

DU

Jose Simoes Mon 11 Sep 2017 6:12PM

Thanks @robertguthrie. Meanwhile, I found the cause, but forgot to update this thread.

Gmail's SMTP breaks the connection immediately on invalid crentials (ignoring the SMTP protocol specification), hence the EOF in the connection stream. So my problem resided in the authentication, as you suggested.

I solved it by changing the SMTP_PORT to 587 and the SMTP_DOMAIN to gmail.com (instead of my own), in loomio's env file. I suspet this will cause a problem in the e-mail's "from" and "reply-to" fields, but it will do for now. I will probably have to find a more suitable SMTP server later.

Cheers!