forked from okfde/froide-theme
-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task: email configuration settings #90
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
|
||
from .base import UipaOrgThemeBase, env | ||
from .base import UipaOrgThemeBase, env, required_env | ||
|
||
class Dev(UipaOrgThemeBase): | ||
DEBUG = True | ||
|
@@ -13,3 +13,46 @@ def TEMPLATES(self): | |
TEMP = super().TEMPLATES | ||
TEMP[0]["OPTIONS"]["debug"] = True | ||
return TEMP | ||
|
||
# Start of email settings | ||
# Read the docs about these settings here: https://github.com/okfde/froide/blob/2dc1899cfe732c3f1d658f07ca86626dd5baa1a3/docs/configuration.rst#settings-for-sending-e-mail | ||
# The exact settings can be seen https://github.com/okfde/froide/blob/2dc1899cfe732c3f1d658f07ca86626dd5baa1a3/froide/settings.py#L618 | ||
|
||
# General email settings | ||
# This is the feature flag for enabling email sending & receiving | ||
# This should be done with caution as it can lead to sending out emails to real public bodies | ||
# It is recommended to create a test public body for testing purposes, so that real public bodies are not contacted | ||
ENABLE_EMAIL = env("ENABLE_EMAIL", False) | ||
|
||
if ENABLE_EMAIL: | ||
SERVER_EMAIL = required_env("SERVER_EMAIL") # This is the inbound address for the SMTP server (i.e. [email protected]) | ||
DEFAULT_FROM_EMAIL = env( | ||
"DEFAULT_FROM_EMAIL", "TEST UIPA.org <[email protected]>" | ||
) | ||
EMAIL_SUBJECT_PREFIX = env("EMAIL_SUBJECT_PREFIX", "[TEST UIPA.org] ") | ||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # This will be different for production | ||
|
||
# These settings are for sending regular email notifications (not FOI requests to public bodies) | ||
EMAIL_HOST = required_env("EMAIL_HOST") # This is the SMTP server for sending mail (i.e. smtp.postmarkapp.com) | ||
EMAIL_PORT = env("EMAIL_PORT", 2525) | ||
EMAIL_HOST_USER = required_env("EMAIL_HOST_USER") # This is the username for the SMTP server (i.e. 12345678-1234-1234-1234-123456789012) - this is the same as the password | ||
EMAIL_HOST_PASSWORD = required_env("EMAIL_HOST_PASSWORD") # This is the password for the SMTP server (i.e. 12345678-1234-1234-1234-123456789012) | ||
EMAIL_USE_TLS = env("EMAIL_USE_TLS", True) | ||
|
||
# These settings are for sending FOI requests to public bodies | ||
FOI_EMAIL_FIXED_FROM_ADDRESS = env("FOI_EMAIL_FIXED_FROM_ADDRESS", True) | ||
FOI_EMAIL_HOST_USER = required_env("FOI_EMAIL_HOST_USER") # This is the username for the SMTP server (i.e. 12345678-1234-1234-1234-123456789012) - this is the same as the password | ||
FOI_EMAIL_HOST_PASSWORD = required_env("FOI_EMAIL_HOST_PASSWORD") # This is the password for the SMTP server (i.e. 12345678-1234-1234-1234-123456789012) | ||
FOI_EMAIL_HOST = required_env("FOI_EMAIL_HOST") # This is the SMTP server for sending mail (i.e. smtp.postmarkapp.com) | ||
FOI_EMAIL_PORT = env("FOI_EMAIL_PORT", 2525) | ||
FOI_EMAIL_USE_TLS = env("FOI_EMAIL_USE_TLS", True) | ||
|
||
# These settings are for receiving FOI responses from public bodies | ||
FOI_EMAIL_HOST_FROM = required_env("FOI_EMAIL_HOST_FROM") # This is the inbound address for the SMTP server (i.e. [email protected]) | ||
# When defining the "FOI_EMAIL_DOMAIN" setting for testing, Postmark enforces that all recipient addresses must share the same domain as the inbound address. | ||
# Basically, if your email address ends in @example.com, then the "FOI_EMAIL_DOMAIN" setting must be set to "example.com". | ||
FOI_EMAIL_DOMAIN = required_env("FOI_EMAIL_DOMAIN") # This defines the "From" address for the inbound email (i.e. beta-foi.uipa.org) | ||
FOI_MAIL_SERVER_HOST = required_env("FOI_MAIL_SERVER_HOST") # This defines the "Message-Id" header for the inbound email (i.e. beta-foi.uipa.org) | ||
|
||
# End of email settings | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to define a new class, say,
EmailTest
, to use for testing sending email via a real SMTP server. This would isolate the configuration from the normal development workflow and prevent confusion about its use.The current setting has the EMAIL_BACKEND set to
django.core.mail.backends.console.EmailBackend
which will print out any email being sent rather than sending it to an SMTP server.