1

我在使用 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 次,我做错了什么?有任何想法吗?谢谢

4

0 回答 0