我在发送带有mandril的电子邮件时遇到问题,我需要在用户注册后两天发送电子邮件,这是我的代码:
bodyEmail="<p>Hey,</p><p>This is my msg</p>"
@sched.interval_schedule(hours=1)
def sendFirst():
today = datetime.datetime.now()
users = Mobile_User.objects.all().filter(emailed=False)
for i in users:
if i.created+datetime.timedelta(hours=48) < today and i.emailed==False:
print i.email
try:
mapi = MailSnakeM('XXXXXXXXXXXXXX', api='mandrill')
mapi.messages.send(message={'html':str(bodyEmail), 'subject':'first email', 'from_email':'me@me.com', 'from_name':'Adrian V', 'to':[{'email':str(i.email)}]})
i.emailed=True
i.save()
except MailSnakeException:
pass
问题是几天后开始反复发送同一封电子邮件,重复发送到同一用户的2或3或4次,我做错了什么?有任何想法吗?感谢