Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 26 May 2020 starting at approximately 10am CDT. It is expected to take around 30 minutes and will involve a short period of downtime, around 5 minutes, towards the end of the maintenance period. Please address any questions, comments, or concerns to uwm-help@cgca.uwm.edu.

Commit 2906f1d7 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Change mechanism for sending emails

Instead of looping over EmailMessage.send() calls, we now get the
email backend and send a list of messages. Note that the backend
sends the messages individually still but this cuts out some of the
overhead.
parent d7ab65db
......@@ -603,7 +603,7 @@ LOGGING = {
'propagate': True,
'level': LOG_LEVEL,
},
'django.request': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': False,
......
......@@ -3,7 +3,7 @@ import logging
import textwrap
from django.conf import settings
from django.core.mail import EmailMessage
from django.core.mail import EmailMessage, get_connection
from django.urls import reverse
from core.time_utils import gpsToUtc
......@@ -143,10 +143,13 @@ def issue_email_alerts(event_or_superevent, alert_type, recipients,
logger.debug("Sending email to {recips}".format(
recips=", ".join([r.email for r in recipients])))
# Send mail individually so all emails are not rejected due to a single
# address being blacklisted
# Construct email messages
messages = []
for recip in recipients:
# Send email
email = EmailMessage(subject=subject, body=email_body,
from_email=settings.ALERT_EMAIL_FROM, to=[recip.email])
email.send()
messages.append(email)
# Send email messages
backend = get_connection()
backend.send_messages(messages)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment