I have a function that runs every hour with apscheduler, this verifies few conditions and according to this sends an email to an arrangement of emails
from mailsnake import MailSnake
mapi = MailSnake('XXXXXXXX', api='mandrill')
def functionEverHour():
users=Users.objects.all()
for users in users:
if users.notificated==False:
mapi.messages.send(message={'html':'sending emails', 'subject':'test', 'from_email':'tes@test.com', 'from_name':'example', 'to':[{'email':str(users.email)}]})
maybe putting this line (mapi = MailSnake('Xajnas12sjnjas', api='mandrill')) in the cycle avoid that kind of mistake?
what does exactly mapi = MailSnake ('Xajnas12sjnjas' api = 'mandrill') that opens a connection to mandrill and never closes and that's the reason I sent emails repetitive (is accumulative?)?
Thanks