mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(settings): OTP mail is sent from the SMTP account, or DEFAULT_FROM_EMAIL
send_mail got no sender, so the OTP mail went out from Django's default webmaster@localhost, which relays that take mail only from their account refuse. DEFAULT_FROM_EMAIL is now read from the environment, defaulting to EMAIL_HOST_USER.
This commit is contained in:
parent
44de77854d
commit
de692271be
3 changed files with 11 additions and 2 deletions
|
|
@ -436,6 +436,8 @@ EMAIL_PORT = int(os.getenv("EMAIL_PORT", "587"))
|
|||
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER", "")
|
||||
## password associated with above email-id
|
||||
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD", "")
|
||||
# the mails' From: relays take mail only from their account (Django's own default is webmaster@localhost)
|
||||
DEFAULT_FROM_EMAIL = os.getenv("DEFAULT_FROM_EMAIL") or EMAIL_HOST_USER or "webmaster@localhost"
|
||||
# seconds an SMTP server may take to answer; without it a server that stops answering holds the request for good
|
||||
EMAIL_TIMEOUT = 10
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from django.test import SimpleTestCase, TestCase, override_settings
|
|||
# every case starts from the defaults.
|
||||
CONFIG_VARS = [
|
||||
"WEBVIRTCLOUD_HTTPS", "WEBVIRTCLOUD_DEBUG", "WEBVIRTCLOUD_SERIAL_CONSOLE", "ALLOWED_HOSTS",
|
||||
"EMAIL_HOST", "EMAIL_PORT", "EMAIL_HOST_USER", "EMAIL_HOST_PASSWORD", "EMAIL_USE_TLS",
|
||||
"EMAIL_HOST", "EMAIL_PORT", "EMAIL_HOST_USER", "EMAIL_HOST_PASSWORD", "EMAIL_USE_TLS", "DEFAULT_FROM_EMAIL",
|
||||
"WEBVIRTCLOUD_DB_HOST", "WEBVIRTCLOUD_DB_PORT", "WEBVIRTCLOUD_DB_NAME",
|
||||
"WEBVIRTCLOUD_DB_USER", "WEBVIRTCLOUD_DB_PASSWORD", "TZ",
|
||||
]
|
||||
|
|
@ -107,6 +107,13 @@ class EmailEnvTestCase(SimpleTestCase):
|
|||
"EMAIL_HOST_PASSWORD": "secret", "EMAIL_USE_TLS": False,
|
||||
})
|
||||
|
||||
def test_the_sender_is_the_smtp_account_unless_set(self):
|
||||
self.assertEqual(load_settings({}, ["DEFAULT_FROM_EMAIL"])["DEFAULT_FROM_EMAIL"], "webmaster@localhost")
|
||||
env = {"EMAIL_HOST_USER": "wvc@example.com"}
|
||||
self.assertEqual(load_settings(env, ["DEFAULT_FROM_EMAIL"])["DEFAULT_FROM_EMAIL"], "wvc@example.com")
|
||||
env["DEFAULT_FROM_EMAIL"] = "WebVirtCloud <noreply@example.com>"
|
||||
self.assertEqual(load_settings(env, ["DEFAULT_FROM_EMAIL"])["DEFAULT_FROM_EMAIL"], "WebVirtCloud <noreply@example.com>")
|
||||
|
||||
|
||||
class DatabaseEnvTestCase(SimpleTestCase):
|
||||
def db(self, env):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue