From 468c2d3993c032fee5553fc4d84182f0d70d5905 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Sat, 20 Jan 2024 00:35:11 +0000 Subject: [PATCH] added documentation, and env variables --- docs/installation.md | 12 ++++++++++++ envs/env | 6 ++++++ envs/env-prod | 5 +++++ webapp/api/api/views.py | 2 +- webapp/api/core/settings.py | 4 ++-- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index b27f4e2d..6f8f9d3f 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -40,6 +40,14 @@ On MAC: https://docs.docker.com/docker-for-mac/#memory On Windows: https://docs.docker.com/docker-for-windows/#resources +### (Optional) SMTP Setup + +For password resets and other emailing services email environment variables are required to be set up. + +Personal email accounts can be set up by users to do this, or you can contact someone in CogStack for a cogstack no email credentials. + +The environment variables required are listed in [Environment Variables.](#(optional)-environment-variables) + ### (Optional) Environment Variables Environment variables are used to configure the app: @@ -48,6 +56,10 @@ Environment variables are used to configure the app: |MEDCAT_CONFIG_FILE|MedCAT config file as described [here](https://github.com/CogStack/MedCAT/blob/master/medcat/config.py)| |BEHIND_RP| If you're running MedCATtrainer, use 1, otherwise this defaults to 0 i.e. False| |MCTRAINER_PORT|The port to run the trainer app on| +|EMAIL_USER|Email address which will be used to send users emails regarding password resets| +|EMAIL_PASS|The password or authentication key which will be used with the email address| +|EMAIL_HOST|The hostname of the SMTP server which will be used to send email (default: mail.cogstack.org)| +|EMAIL_PORT|The port that the SMTP server is listening to, common numbers are 25, 465, 587 (default: 465)| Set these and re-run the docker-compose file. diff --git a/envs/env b/envs/env index 1b3aa62f..202b4aac 100644 --- a/envs/env +++ b/envs/env @@ -33,3 +33,9 @@ RESUBMIT_ALL_ON_STARTUP=1 # Front end env vars LOAD_NUM_DOC_PAGES=10 + +# SMTP EMAIL SETTINGS +EMAIL_USER=example@example.com +EMAIL_PASS=tobechanged +EMAIL_HOST=mail.cogstack.org +EMAIL_PORT=465 \ No newline at end of file diff --git a/envs/env-prod b/envs/env-prod index 0026437c..baf3ce6c 100644 --- a/envs/env-prod +++ b/envs/env-prod @@ -35,3 +35,8 @@ RESUBMIT_ALL_ON_STARTUP=1 # Front end env vars LOAD_NUM_DOC_PAGES=10 +# SMTP EMAIL SETTINGS +EMAIL_USER=example@example.com +EMAIL_PASS=tobechanged +EMAIL_HOST=mail.cogstack.org +EMAIL_PORT=465 \ No newline at end of file diff --git a/webapp/api/api/views.py b/webapp/api/api/views.py index 3afca0e6..0cadeaa3 100644 --- a/webapp/api/api/views.py +++ b/webapp/api/api/views.py @@ -222,7 +222,7 @@ def post(self, request, *args, **kwargs): try: return super().post(request, *args, **kwargs) except SMTPException: - return HttpResponseServerError('''SMTP settings have not been configured.
+ return HttpResponseServerError('''SMTP settings are not configured correctly.
Please visit https://medcattrainer.readthedocs.io for more information to resolve this.
You can also ask a question at: https://discourse.cogstack.org/c/medcat/5''') diff --git a/webapp/api/core/settings.py b/webapp/api/core/settings.py index 29b4789b..ce3de7a1 100644 --- a/webapp/api/core/settings.py +++ b/webapp/api/core/settings.py @@ -198,8 +198,8 @@ # EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -EMAIL_HOST = 'smtp.gmail.com' -EMAIL_PORT = 587 +EMAIL_HOST = os.environ.get('EMAIL_HOST') +EMAIL_PORT = os.environ.get('EMAIL_PORT') EMAIL_HOST_USER = os.environ.get('EMAIL_USER') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS') EMAIL_USE_TLS = True \ No newline at end of file