diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2019-06-29 01:50:43 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-02 07:34:07 +0200 |
| commit | 090ca6512f514556394d4a8d321db7883f03e2a6 (patch) | |
| tree | 3f36f7d97c8910b0eb6be962ef64ef44baa8c9e8 /django | |
| parent | 29240a99526f5f2a234a9093cd7e001f32ba1801 (diff) | |
Fixed #30604 -- Made mail_admins()/mail_managers() raise ValueError if ADMINS/MANAGERS is set incorrectly.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/mail/__init__.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py index 05c8c6a1b1..d17058b0d4 100644 --- a/django/core/mail/__init__.py +++ b/django/core/mail/__init__.py @@ -91,6 +91,8 @@ def mail_admins(subject, message, fail_silently=False, connection=None, """Send a message to the admins, as defined by the ADMINS setting.""" if not settings.ADMINS: return + if not all(isinstance(a, (list, tuple)) and len(a) == 2 for a in settings.ADMINS): + raise ValueError('The ADMINS setting must be a list of 2-tuples.') mail = EmailMultiAlternatives( '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message, settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS], @@ -106,6 +108,8 @@ def mail_managers(subject, message, fail_silently=False, connection=None, """Send a message to the managers, as defined by the MANAGERS setting.""" if not settings.MANAGERS: return + if not all(isinstance(a, (list, tuple)) and len(a) == 2 for a in settings.MANAGERS): + raise ValueError('The MANAGERS setting must be a list of 2-tuples.') mail = EmailMultiAlternatives( '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message, settings.SERVER_EMAIL, [a[1] for a in settings.MANAGERS], |
