perf: 优化发送邮件

pull/11721/head
ibuler 2023-09-27 10:31:44 +08:00 committed by Bryan
parent 56a26481a4
commit 2069fee795
1 changed files with 4 additions and 1 deletions

View File

@ -36,7 +36,9 @@ def send_mail_async(*args, **kwargs):
args[0] = (settings.EMAIL_SUBJECT_PREFIX or '') + args[0]
from_email = settings.EMAIL_FROM or settings.EMAIL_HOST_USER
args.insert(2, from_email)
args = tuple(args)
args[3] = [mail for mail in args[3] if mail != 'admin@mycomany.com']
args = tuple(args)
try:
return send_mail(*args, **kwargs)
@ -50,6 +52,7 @@ def send_mail_attachment_async(subject, message, recipient_list, attachment_list
attachment_list = []
from_email = settings.EMAIL_FROM or settings.EMAIL_HOST_USER
subject = (settings.EMAIL_SUBJECT_PREFIX or '') + subject
recipient_list = [mail for mail in recipient_list if mail != 'admin@mycomany.com']
email = EmailMultiAlternatives(
subject=subject,
body=message,