Skip to content

Commit

Permalink
Force application to use file based email backend when specified in s…
Browse files Browse the repository at this point in the history
…ettings (#354)

* Force application to use file based email backend when specified in settings.

* Update docs
  • Loading branch information
djperrefort authored Aug 1, 2024
1 parent bb772e6 commit a188d0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/install/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ The following settings are intended exclusively for use in development.
| Setting Name | Default Value | Description |
|---------------------------|--------------------------|---------------------------------------------------------------|
| `DEBUG` | `False` | Enable or disable in browser error tracebacks. |
| `DEBUG_EMAIL_DIR` | `<app>/email_files` | Write emails to disk instead of using the SMTP server. |
| `DEBUG_EMAIL_DIR` | `` | Write emails to disk instead of using the SMTP server. |
18 changes: 8 additions & 10 deletions keystone_api/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,18 @@

# Email server

if DEBUG:
if _email_path := env.get_value('DEBUG_EMAIL_DIR', default=None):
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = _email_path

else:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

EMAIL_FILE_PATH = env.path('DEBUG_EMAIL_DIR', BASE_DIR / 'email_files')

EMAIL_HOST = env.str('EMAIL_HOST', 'localhost')
EMAIL_PORT = env.int('EMAIL_PORT', 25)
EMAIL_HOST_USER = env.str('EMAIL_HOST_USER', '')
EMAIL_HOST_PASSWORD = env.str('your_email_password', '')
EMAIL_USE_TLS = env.bool('EMAIL_USE_TLS', False)
EMAIL_FROM_ADDRESS = env.str('EMAIL_FROM_ADDRESS', '[email protected]')
EMAIL_HOST = env.str('EMAIL_HOST', 'localhost')
EMAIL_PORT = env.int('EMAIL_PORT', 25)
EMAIL_HOST_USER = env.str('EMAIL_HOST_USER', '')
EMAIL_HOST_PASSWORD = env.str('your_email_password', '')
EMAIL_USE_TLS = env.bool('EMAIL_USE_TLS', False)
EMAIL_FROM_ADDRESS = env.str('EMAIL_FROM_ADDRESS', '[email protected]')

# Database

Expand Down

0 comments on commit a188d0b

Please sign in to comment.