overleaf icon indicating copy to clipboard operation
overleaf copied to clipboard

Unable to correctly set up SMTP service

Open AugustoGarcia opened this issue 4 years ago • 8 comments

Steps to Reproduce

  1. Create docker container with docker-compose, everything else works correctly
  2. Set up STMP Gmail service SHARELATEX_ADMIN_EMAIL = [email protected] SHARELATEX_EMAIL_SMTP_PASS = somepassword SHARELATEX_EMAIL_SMTP_USER = [email protected] SHARELATEX_EMAIL_SMTP_SECURE = true SHARELATEX_EMAIL_SMTP_PORT = 587 SHARELATEX_EMAIL_SMTP_HOST = smtp.gmail.com
  3. Send test email

Expected Behaviour

A test email should be received

Observed Behaviour

No email is received. I see nothing in the logs concerning smtp

Context

Technical Info

  • URL: n/a
  • Browser Name and version: n/a
  • Operating System and version (desktop or mobile): n/a
  • Signed in as: n/a
  • Project and/or file: n/a

Analysis

Thanks for any help/input!

AugustoGarcia avatar Nov 20 '20 17:11 AugustoGarcia

Indeed, I don't see anything related to mails in the logs as well. Mails and invites got broken when upgrading from 2.5.0 to 2.5.2 for me, and it's hard finding out why because there is nothing in the logs at all. :see_no_evil:

fnetX avatar Jan 30 '21 13:01 fnetX

Hi @fnetX the only change in 2.5.2 is related to how the email address is stored in the tokens table (lowercase is now enforced): https://github.com/overleaf/overleaf/blob/master/hotfix/2.5.2/create-token-lowercase-email.patch

Do you have problems with any email address or only those with a lower/uppercase mix?

mserranom avatar Feb 01 '21 11:02 mserranom

Well, my issue is probably not exactly about mailing, sharing via email stopped working at all. I cannot share documents from [email protected] to [email protected], nor can [email protected] share docs to [email protected] - the invite doesn't even show up in the dashboard.

I can't find anything useful in the logs.

fnetX avatar Feb 01 '21 20:02 fnetX

I now managed to get this from the logs via bin/logs -f web:

{"name":"web","hostname":"0b4b593a96b8","pid":157,"level":50,"err":{"message":"error sending message","name":"OError","stack":"OError: error sending message\n    at Object.sendEmail (/var/www/sharelatex/web/app/src/Features/Email/EmailSender.js:100:11)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)\ncaused by:\n    Error: 139984895788928:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:\n    ","info":{}},"projectId":"6023e040b0d17200762abe3c","email":"[email protected]","msg":"error sending messages for invite","time":"2021-04-27T11:19:31.831Z","v":0}

How can I find out more? Probably related: #750

fnetX avatar Apr 27 '21 11:04 fnetX

This fixed my setup, actually. I wonder why the behaviour changed, because it worked at the beginning. Never mind, now mail is working again. The explanation of these vars and troubleshooting is not very prominent tbh, but I can't care about that right now. Setting the SECURE var to false feels a bit off actually, and I wonder why this is necessary, since my server supports both STARTTLS and normal TLS :shrug:

fnetX avatar May 04 '21 19:05 fnetX

I was able to fix it using the following config, with a custom mail server with TLS enabled:

SHARELATEX_EMAIL_SMTP_IGNORE_TLS: "false" (mind the " " in all first three) SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH: "false" SHARELATEX_EMAIL_SMTP_SECURE: "true" SHARELATEX_ADMIN_EMAIL: "[email protected]" SHARELATEX_EMAIL_SMTP_PASS: "yourpassword" SHARELATEX_EMAIL_SMTP_USER: "[email protected]" SHARELATEX_EMAIL_SMTP_PORT: "465" (587 does not work even if enabled) SHARELATEX_EMAIL_SMTP_HOST: "your.mailserver.address"

AugustoGarcia avatar Jun 21 '21 01:06 AugustoGarcia

It works for me as @fnetX suggests with:

SHARELATEX_EMAIL_SMTP_IGNORE_TLS: "false" SHARELATEX_EMAIL_SMTP_TLS_REJECT_UNAUTH: "false" SHARELATEX_EMAIL_SMTP_SECURE: "false" SHARELATEX_EMAIL_SMTP_PORT: "587"

I just add two points. I had to setup port 587, as I had 465 setup.

ports: - 587:587

The big issue for me is that I was using smtp.gmail.com as my host, but I have 2-factor authentication turned on on my gmail account. So for my password I have to use an app password as explained here.

mhsiggers avatar Oct 14 '22 23:10 mhsiggers

I've uploaded a workaround in a gist: https://gist.github.com/scmanjarrez/8f8ded964e1aebd57721c2cd364bbab7

scmanjarrez avatar May 25 '23 12:05 scmanjarrez