Skip to content

Commit

Permalink
added documentation, and env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Sutton committed Jan 20, 2024
1 parent d882c15 commit 468c2d3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
12 changes: 12 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.

Expand Down
6 changes: 6 additions & 0 deletions envs/env
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ RESUBMIT_ALL_ON_STARTUP=1

# Front end env vars
LOAD_NUM_DOC_PAGES=10

# SMTP EMAIL SETTINGS
[email protected]
EMAIL_PASS=tobechanged
EMAIL_HOST=mail.cogstack.org
EMAIL_PORT=465
5 changes: 5 additions & 0 deletions envs/env-prod
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ RESUBMIT_ALL_ON_STARTUP=1
# Front end env vars
LOAD_NUM_DOC_PAGES=10

# SMTP EMAIL SETTINGS
[email protected]
EMAIL_PASS=tobechanged
EMAIL_HOST=mail.cogstack.org
EMAIL_PORT=465
2 changes: 1 addition & 1 deletion webapp/api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br>
return HttpResponseServerError('''SMTP settings are not configured correctly. <br>
Please visit https://medcattrainer.readthedocs.io for more information to resolve this. <br>
You can also ask a question at: https://discourse.cogstack.org/c/medcat/5''')

Expand Down
4 changes: 2 additions & 2 deletions webapp/api/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 468c2d3

Please sign in to comment.