Fail on missing from_address

This commit is contained in:
Victor "multun" Collod 2019-03-08 18:53:21 +01:00
parent f53fd92cd3
commit 6afd791bef
2 changed files with 5 additions and 5 deletions

View file

@ -10,6 +10,10 @@ def _declare_backend(backend_path):
backend_module = importlib.import_module(backend_module_name)
backend = getattr(backend_module, class_name)
return backend(*args, **kwargs)
if from_address is None:
raise ValueError("missing from_address")
_backend.from_address = from_address
_backend.headers = headers
return _backend

View file

@ -46,11 +46,7 @@ def todo_get_mailer(user, task):
if task_backend is None:
return (None, mail.get_connection)
from_address = getattr(task_backend, "from_address", None)
if from_address is None:
# worst fallback ever
from_address = user.email
from_address = getattr(task_backend, "from_address")
from_address = email.utils.formataddr((user.username, from_address))
return (from_address, task_backend)