misc: ignore mail redirection for traceback emails (#45708)

This commit is contained in:
Frédéric Péters 2020-08-03 17:25:32 +02:00
parent dd74381365
commit 8793d3c0e0
2 changed files with 11 additions and 9 deletions

View File

@ -162,7 +162,7 @@ def email(subject, mail_body, email_rcpt, replyto=None, bcc=None,
email_from=None, exclude_current_user=False, email_type=None,
want_html=True, hide_recipients=False, fire_and_forget=False,
smtp_timeout=None, attachments=(),
extra_headers=None):
extra_headers=None, ignore_mail_redirection=False):
if not get_request():
# we are not processing a request, no sense delaying the handling
@ -325,13 +325,14 @@ def email(subject, mail_body, email_rcpt, replyto=None, bcc=None,
if len(rcpts) == 0:
return
mail_redirection = get_cfg('debug', {}).get('mail_redirection')
if mail_redirection:
rcpts = [mail_redirection]
if os.environ.get('QOMMON_MAIL_REDIRECTION'):
# if QOMMON_MAIL_REDIRECTION is set in the environment, send all emails
# to that address instead of the real recipients.
rcpts = [os.environ.get('QOMMON_MAIL_REDIRECTION')]
if not ignore_mail_redirection:
mail_redirection = get_cfg('debug', {}).get('mail_redirection')
if mail_redirection:
rcpts = [mail_redirection]
if os.environ.get('QOMMON_MAIL_REDIRECTION'):
# if QOMMON_MAIL_REDIRECTION is set in the environment, send all emails
# to that address instead of the real recipients.
rcpts = [os.environ.get('QOMMON_MAIL_REDIRECTION')]
email_to_send = EmailToSend(email_from, rcpts, msg, smtp_timeout)
if not fire_and_forget:

View File

@ -38,7 +38,8 @@ class ApplicationLogger(DefaultLogger):
email_rcpt=[self.error_email],
want_html=False,
fire_and_forget=True,
extra_headers=headers)
extra_headers=headers,
ignore_mail_redirection=True)
class BotFilter(logging.Filter):