feat(email): add email configuration support
Configured email backend to use SMTP, console, or file-based backends based on settings. Added fallback values to handle various configurations. Updated `.gitignore` to exclude email files. This enhances email handling capabilities and ensures configuration flexibility.
This commit is contained in:
parent
e7a7766351
commit
c7a36d2ebe
2 changed files with 21 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,3 +8,4 @@ media/
|
||||||
.venv/
|
.venv/
|
||||||
venv/
|
venv/
|
||||||
/static/
|
/static/
|
||||||
|
/emails/
|
|
@ -168,3 +168,22 @@ REST_FRAMEWORK = {
|
||||||
"rest_framework.permissions.IsAuthenticated",
|
"rest_framework.permissions.IsAuthenticated",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Mail
|
||||||
|
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
|
if (email_host := CONFIG.get("Email", "Host", fallback=None)) is not None:
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
||||||
|
EMAIL_HOST = email_host
|
||||||
|
EMAIL_PORT = CONFIG.getint("Email", "Port", fallback=25)
|
||||||
|
EMAIL_USE_TLS = CONFIG.getboolean("Email", "TLS", fallback=False)
|
||||||
|
EMAIL_USE_SSL = CONFIG.getboolean("Email", "SSL", fallback=False)
|
||||||
|
EMAIL_HOST_USER = CONFIG.get("Email", "Username")
|
||||||
|
EMAIL_HOST_PASSWORD = CONFIG.get("Email", "Password")
|
||||||
|
|
||||||
|
else:
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
|
||||||
|
EMAIL_FILE_PATH = "emails"
|
||||||
|
|
||||||
|
EMAIL_SUBJECT_PREFIX = "[FreeDOI] "
|
Loading…
Reference in a new issue