def sent_register_email(email, sent_type='register'): # email = data[0] # sent_type = data[1] email_record = EmailVerifyRecord() code = random_str(32) email_record.code = code email_record.email = email email_record.sent_type = sent_type email_record.save() # 发送邮件 if sent_type == "register": email_title = "注册用户在线激活链接" email_body = "点击以下链接激活你的账号:{}/user/activate/?code={}".format( HOST, code) # print("内容准备完成 发送") # 主题 内容 发件人 收件人(列表) sent_status = send_mail(email_title, email_body, EMAIL_FROM, [email], fail_silently=False) if sent_status: pass # print("sent success") pass elif sent_type == "forget": email_title = "密码重置链接" email_body = "点击以下链接重置你的密码:{}/user/reset/password/?code={}".format( HOST, code) # 主题 内容 发件人 收件人(列表) sent_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if sent_status: pass else: pass
def sent_register_email(email, sent_type='register'): email_record = EmailVerifyRecord() code = random_str(32) email_record.code = code email_record.email = email email_record.sent_type = sent_type email_record.save() # 发送邮件 if sent_type == "register": email_title = "注册用户在线激活链接" email_body = "点击以下链接激活你的账号:http://{}/activate/?code={}".format( HOST, code) print("新注册用户 发送邮件") # 主题 内容 发件人 收件人(列表) sent_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if sent_status: pass print("ok") pass elif sent_type == "forget": print("忘记密码 发送邮件") email_title = "密码重置链接" email_body = "点击以下链接重置你的密码:http://{}/reset/password/?code={}".format( ACTIVATE_HOST, code) # 主题 内容 发件人 收件人(列表) sent_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if sent_status: pass else: pass