diff --git a/.gitignore b/.gitignore index 9de8853..fb1a1c2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ static/js/* media/ .venv/ venv/ -/static/ \ No newline at end of file +/static/ +/emails/ \ No newline at end of file diff --git a/freedoi/settings.py b/freedoi/settings.py index 5eb7bf5..fc1b67e 100644 --- a/freedoi/settings.py +++ b/freedoi/settings.py @@ -168,3 +168,22 @@ REST_FRAMEWORK = { "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] " \ No newline at end of file