Example #1
0
def sendReceivePasswordMail(user ,request):
    now = datetime.datetime.now()
    token = getValidationToken(user,now)
    template = loader.get_template("accounts/resetPasswordMail.html")
    context = Context({"userName":user.username,"baseURL":getUrlBaseForLocalServer(request),"token":token,"deadline":(now + datetime.timedelta(days=RESET_PASSWORD_MAIL_AVAILABLE_TIME)).strftime("%Y-%m-%d %H:%M:%S")})
    body = template.render(context)
    send_mail("*****@*****.**",[user.email],"优乐校园提醒你:重置密码",body)
Example #2
0
def sendValidationMail(registerUser,request):
    lastSendTime = registerUser.lastSendTime
    now = datetime.datetime.now()
    if lastSendTime:
        deadline = lastSendTime + datetime.timedelta(days=REGISTER_MAIL_AVAILABLE_TIME)
        if now < deadline:
            #失效,重新发送验证邮件
            print "email have been sent already! please don't repeat"
            pass
    registerUser.lastSendTime = now
    registerUser.save()
    token = getValidationToken(registerUser,now)
    template = loader.get_template("accounts/registerMailValidate.html")
    context = Context({"userName":registerUser.username,"baseURL":getUrlBaseForLocalServer(request),"token":token,"deadline":(now + datetime.timedelta(days=REGISTER_MAIL_AVAILABLE_TIME)).strftime("%Y-%m-%d %H:%M:%S")})
    body = template.render(context)
    send_mail("*****@*****.**",[registerUser.email],"登录验证",body)