Merge pull request #183 from CDC-IITDH/fixed-mailer
fixed mailer to send mails in batches
This commit is contained in:
commit
7ef5c9aac4
|
@ -214,14 +214,16 @@ def sendEmail(email_to, subject, data, template, attachment_jnf_response=None):
|
||||||
else:
|
else:
|
||||||
recipient_list = [str(email_to), ]
|
recipient_list = [str(email_to), ]
|
||||||
|
|
||||||
msg = EmailMultiAlternatives(subject, text_content, email_from,None,bcc=recipient_list)
|
#batch 100 ppl to send as bcc
|
||||||
msg.attach_alternative(html_content, "text/html")
|
for i in range(0,len(recipient_list),100):
|
||||||
if attachment_jnf_response:
|
msg = EmailMultiAlternatives(subject, text_content, email_from,None,bcc=recipient_list[i:i+100])
|
||||||
# logger.info(attachment_jnf_response)
|
msg.attach_alternative(html_content, "text/html")
|
||||||
pdf = pdfkit.from_string(attachment_jnf_response['html'], False,
|
if attachment_jnf_response:
|
||||||
options={"--enable-local-file-access": "", '--dpi': '96'})
|
# logger.info(attachment_jnf_response)
|
||||||
msg.attach(attachment_jnf_response['name'], pdf, 'application/pdf')
|
pdf = pdfkit.from_string(attachment_jnf_response['html'], False,
|
||||||
msg.send()
|
options={"--enable-local-file-access": "", '--dpi': '96'})
|
||||||
|
msg.attach(attachment_jnf_response['name'], pdf, 'application/pdf')
|
||||||
|
msg.send()
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
logger.error("Send Email: " + str(sys.exc_info()))
|
logger.error("Send Email: " + str(sys.exc_info()))
|
||||||
|
|
Loading…
Reference in New Issue