Merge pull request #183 from CDC-IITDH/fixed-mailer

fixed mailer to send mails in batches
This commit is contained in:
karthik mv 2023-10-27 17:31:50 +05:30 committed by GitHub
commit 7ef5c9aac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -214,7 +214,9 @@ def sendEmail(email_to, subject, data, template, attachment_jnf_response=None):
else:
recipient_list = [str(email_to), ]
msg = EmailMultiAlternatives(subject, text_content, email_from,None,bcc=recipient_list)
#batch 100 ppl to send as bcc
for i in range(0,len(recipient_list),100):
msg = EmailMultiAlternatives(subject, text_content, email_from,None,bcc=recipient_list[i:i+100])
msg.attach_alternative(html_content, "text/html")
if attachment_jnf_response:
# logger.info(attachment_jnf_response)