Skip to content

Commit

Permalink
fix(settings): enable email settings without email error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
trowik committed Jan 10, 2023
1 parent 20f5f2b commit 1469030
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 5 additions & 3 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ Users of nginx/apache must ensure to have matching CORS configurations.
* `PAGINATION_DEFAULT_PAGE_SIZE`: the default page size if no query param (`page_size`) is given (default: `100`)
* `PAGINATION_MAX_PAGE_SIZE`: the max value of the page size query param (`page_size`) (default: `1000`)

## Email error handler
* `ENABLE_ADMIN_EMAIL_LOGGING`: enable Django to send email to admins on errors (default: `False`)
## Email
* `SERVER_EMAIL`: the email address that error messages come from
* `EMAIL_HOST`: the host to use for sending email (default: `localhost`)
* `EMAIL_PORT`: port to use for the SMTP server (default: `25`)
* `EMAIL_HOST_USER`: username for the SMTP server(default: "")
* `EMAIL_HOST_PASSWORD`: password for the SMTP server user (default: "")
* `EMAIL_USE_TLS`: whether to use an implicit TLS (secure) connection when talking to the SMTP server (default: `False`)
* `ADMINS`: list of people who will get code error notifications. Items in the list should follow this example: `Test Example <[email protected]>,Test2 <[email protected]>`

If either `EMAIL_HOST_USER` or `EMAIL_HOST_PASSWORD` is empty, Django won't attempt authentication.

## Email error handler
* `ENABLE_ADMIN_EMAIL_LOGGING`: enable Django to send email to admins on errors (default: `False`)
* `ADMINS`: list of people who will get code error notifications. Items in the list should follow this example: `Test Example <[email protected]>,Test2 <[email protected]>`
14 changes: 8 additions & 6 deletions document_merge_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ def parse_admins(admins):
URL_PREFIX = env.str("URL_PREFIX", default="")

# Email settings
SERVER_EMAIL = env.str("SERVER_EMAIL", default="root@localhost")
EMAIL_HOST = env.str("EMAIL_HOST", default="localhost")
EMAIL_PORT = env.int("EMAIL_PORT", default=25)
EMAIL_HOST_USER = env.str("EMAIL_HOST_USER", default="")
EMAIL_HOST_PASSWORD = env.str("EMAIL_HOST_PASSWORD", default="")
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", default=False)

# Email error handler
if ENABLE_ADMIN_EMAIL_LOGGING: # pragma: no cover
LOGGING["loggers"]["django"]["handlers"].append("mail_admins") # type: ignore
SERVER_EMAIL = env.str("SERVER_EMAIL", default="root@localhost")
EMAIL_HOST = env.str("EMAIL_HOST", default="localhost")
EMAIL_PORT = env.int("EMAIL_PORT", default=25)
EMAIL_HOST_USER = env.str("EMAIL_HOST_USER", default="")
EMAIL_HOST_PASSWORD = env.str("EMAIL_HOST_PASSWORD", default="")
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", default=False)

0 comments on commit 1469030

Please sign in to comment.