def send_register_email(email, send_type='register'): email_record = VerifyCode() # 生成一个16位长的随机字符串 code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() email_title = "" email_body = "" if send_type == 'register': email_title = '注册激活链接' email_body = '点击下面的链接激活你的帐号 :http://127.0.0.1:8000/user/active/{0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == 'forget': email_title = '找回密码链接' email_body = '点击下面的链接修改的帐号密码 :http://127.0.0.1:8000/user/reset/{0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def addver(self): verifycode_list = [] for verifycode in verifycodes_data: verfy = VerifyCode() verfy.code = verifycode["code"] verfy.mobile = verifycode["mobile"] verifycode_list.append(verfy) VerifyCode.objects.bulk_create(verifycode_list)
def send_email_code(email, code): email_ver = VerifyCode() email_ver.email = email email_ver.code = code email_ver.save() print('code', code) #第二步,准备参数发送邮件 send_title = '欢迎注册天天生鲜在线网站' send_body = f'你的验证码:{code}\n 是请点击以下链接进行激活:\n ' + EMAIL_REGISTER send_mail(send_title, send_body, EMAIL_FROM, [email])