From 724c2c84dac6652f10f196e0f0f4fc871ad9e3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 15 Apr 2020 23:38:31 +0200 Subject: [PATCH] Make sure all emails are stored to a tmp file in development In development, emails sent from edx-platform were using the "file_email" channel from edx-ace ("edX's automated communication engine"). This channel was failing because it tries to write to a file located in the /edx folder, which does not exist in tutor containers. To fix this, we configure edx-ace to rely on the django email backend, which itself is configured to send emails to a file in development. It turns out that this backend was also configured to store emails in a file located in the /edx folder, so we had to add the standard EMAIL_FILE_PATH django setting to our development settings. It was easier to reconfigure the django file email backend than the edx-ace file_email channel because the output path of the latter cannot be modified by a setting. Note that this causes all emails to be stored in local files instead of being sent to actual recipients. This is the default behaviour in Open edX, and indeed in most default django apps (in development). This is a good thing! If, for some reason, developers would like to try out email sending during development, they should modify the EMAIL_BACKEND setting and set it to 'django.core.mail.backends.smtp.EmailBackend'. This is quite easy to achieve with the help of a plugin: name: sendemailsindev version: 0.1.0 patches: openedx-development-settings: | # actually send emails in dev EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" Close #315 --- CHANGELOG.md | 1 + .../templates/apps/openedx/settings/partials/common_all.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c1fd4..260bae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Bugfix] Make sure all emails (including "password reset") are properly saved to a local file in development mode (#315) - [Improvement] Add `openedx-development-settings` patch to patch the LMS and the CMS simultaneously in development - [Bugfix] Fix missing celery tasks in the CMS diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index 08d6cfe..e3d1ecd 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -37,7 +37,13 @@ LOGGING["handlers"]["tracking"] = { } LOGGING["loggers"]["tracking"]["handlers"] = ["console", "local", "tracking"] +# Email EMAIL_USE_SSL = {{ SMTP_USE_SSL }} +# Forward all emails from edX's Automated Communication Engine (ACE) to django. +ACE_ENABLED_CHANNELS = ["django_email"] +ACE_CHANNEL_DEFAULT_EMAIL = "django_email" +ACE_CHANNEL_TRANSACTIONAL_EMAIL = "django_email" +EMAIL_FILE_PATH = "/tmp/openedx/emails" LOCALE_PATHS.append("/openedx/locale")