def send( self ):
c = Context({ "content": self.introductory_text, "user":None, "request":None, "updates": [] })#Section.updates.all()[:20] })
t = loader.get_template('emailer/html/updates.html')
subject = self.subject
recipients = []
if self.to_all_principal_contacts:
self.add_principal_contacts()
if self.to_all_subscribers:
self.add_subscribers()
for i in self.recipients.all():
recipients.append( i.email )
self.save()
html = t.render(c)
for i in recipients:
send_html_email( subject, html, "
emailataddress.com", i, image_root=settings.PROJECT_DIR )
from datetime import datetime
self.sent_on = datetime.now()
self.sent = True
self.save()
What I want to do is break recipients[] into chunks of say 100 and then send_html_email on each email address within each chunk for all chunks BUT I want to preserve the self.sent = True self.save() to be done after all chunks have been sent.
I think it may also need some method of timebreak between each chunk being processed.
This is come about because the server/host seems to have a problem with sending 1500 emails in one go. The above sends to small numbers but not all in one go.
Thanks for helping