Unable to send email through SMTP for user activation in docker

Hi,
I have setup a docker instance of Kobotoolbox successfully. I am able to login as admin and also create forms from the docker instance. However, when I try to create a new account (user) with different email id, it says an activation email is sent. However, i do not receive any emails. I checked the SMTP settings - everything seems to be fine. I even tried the same using ssmtp with the same SMTP settings and I am able to receive emails. However, when trying to activate user through Kobo toolbox, I am not receiving any email.

The SMTP settings in envfiles/smtp.txt is given below (email id and password is removed in this message for security reasons):

EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_HOST_USER=******** EMAIL_HOST_PASSWORD=******* EMAIL_USE_TLS=True DEFAULT_FROM_EMAIL=**@

Any help appreciated.Thanks!

Regards

Dev

Hi All,
After bringing down the docker containers and bringing it up again, I have started receiving user activation emails - thanks and apologies for the trouble, if any.

Regards

Dev

···

On Wednesday, 10 January 2018 10:54:38 UTC+5:30, Dev wrote:

Hi,
I have setup a docker instance of Kobotoolbox successfully. I am able to login as admin and also create forms from the docker instance. However, when I try to create a new account (user) with different email id, it says an activation email is sent. However, i do not receive any emails. I checked the SMTP settings - everything seems to be fine. I even tried the same using ssmtp with the same SMTP settings and I am able to receive emails. However, when trying to activate user through Kobo toolbox, I am not receiving any email.

The SMTP settings in envfiles/smtp.txt is given below (email id and password is removed in this message for security reasons):

EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587 EMAIL_HOST_USER=******** EMAIL_HOST_PASSWORD=******* EMAIL_USE_TLS=True DEFAULT_FROM_EMAIL=**@

Any help appreciated.Thanks!

Regards

Dev

1 Like

I am with the same problem but I cannot solve it. Could you detail how to solve it please? Thank you very much

I am facing the same problem. My set-up is ok but only the emails are not sending. How dis you fix please assist.

Hi Alex,
Welcome to the community forum, since this is an installation on your own servers we will wait to see if there are other users who have had a similar experience and an accompanying solution.

Stephane

I was able to fix the error:

1: Bought private email from Namecheap
2: My Domain name Nameservers were pointing to Digital Ocean
3: I set the MX, CNAME, TXT and SRV from namecheap private email to Digital Ocean since I linked my domain to the droplet.
4: On Kobotoolbox account I made sure super admin email is the email I had purchased.

SMTP set-up onfigurations:

EMAIL_HOST=mail.privateemail.com
EMAIL_PORT=587
EMAIL_HOST_USER=youremailaddress
EMAIL_HOST_PASSWORD=youremailpassword
EMAIL_USE_TLS=True
DEFAULT_FROM_EMAIL=youremailaddress

This worked for me hope it helps someone else who is facing the same.

2 Likes

Hi @alexgmuriithi,

Thank you for sharing the solution to the entire community! It should help those having similar issues. Expecting the same in the upcoming days!

Have a great day!

Hi Alex

What did you do with the “Email_backend” line - did you delete it or change it?
Thanks!

EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend

1 Like

I have got it working now - MFA was causing the issue.
Its working on office365 SMTP

2 Likes

Hi @jparmar,

Thank you for sharing the solution to the entire community! It should be very helpful to users having similar issues.

Have a great day!

I’m not sure if I should create a new thread or continue this one, but I too have trouble with setting up the smtp.

It boils down to the fact that:

  1. I’m not sure where to change the smtp settings
  2. I’m not sure when running python3 run.py --setup if changing the smtp settings are really taken into account (do you need to rebuild the docker image each time you want to try out a new setting?)
  3. There is no place that I know of in the kobotoolbox admin pages where you can check the current smtp settings, lest change them on the fly
  4. I do not know which log could show me which errors are thrown

To sum up:

  • I can create users (and check those from the django admin page), however I get 504 gateway time-out errors and never receive any emails from my kobotoolbox installation
  • I’ve triple checked my smtp settings and those works when used in an email client on my laptop
  • Does Docker blocks port 465 (which is used by my MX provider)?
  • I’ve tried changing the .run.conf file with:
"smtp_host": "mail.gandi.net",
"smtp_password": "thePassword",
"smtp_port": "465",
"smtp_use_tls": "1",
"smtp_user": "myuser@mydomain.com",

…the relaunch kobo with python3 run.py, but I still get gateway time-out errors.

Where does the EMAIL_* variable mentioned above are stored?
Would you see any problem that I might have missed?
Thanks!

Taking a look at: kpi repo:
./kpi/kobo/settings/base.py Line 491

We have that config only will accept EMAIL_USE_TLS , but according docs

we can use EMAIL_USE_SSL.
In my case I use a Bluehost mail server which doesn’t work with TLS, most probably Django uses a STARTTLS command, but we need to connect through SSL. I’ve done a POC on a console app and that is how it should work.

I wasn’t able to work with gmail either but I think is because Gmail is blocking a connection from a U.S. in Azure (I live in Bolivia), but that’s another story.

So… should we think that KPI only support TLS? or is there any way to make it work with SSL? thanks!!

You can change them with kobo-install --setup. The changes are really taken into account after a full down/up cycle.
If you want to test it on the fly, you have to go inside the container, edit the Django config file and kill uwsgi.

No, docker does not block any ports (AFAIK)
All the environments variables are stored in files within the folder kobo-env which should be located at the same level as your kobo-docker folder.

You don’t need to rebuild the docker image but you need to re-up the containers with --force-recreate option because the environment variables are passed to the containers when they up only.

1 Like

You are right. KPI only supports TLS,
You can still post a PR to KPI repository with the changes to support SSL.

1 Like