def send_register_email(email, send_type='register'): code = random_str() if send_type == 'sendemail_code': code = random_str(4) email_record = EmailVerifyRecord() email_record.email = email email_record.send_type = send_type email_record.code = code email_record.save() if send_type == 'register': email_title = '慕学在线网注册激活链接' email_body = '请点击下面的链接注册你的账号 https://andersonshao.com/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 = '请点击下面的链接重置密码 https://andersonshao.com/reset/{0}'.format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == 'sendemail_code': email_title = '慕学在线网修改邮箱' email_body = '你的验证码为 {0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): # 发送之前先保存到数据库,到时候查询链接是否存在 # 实例化一个EmailVerifyRecord对象 email_record = EmailVerifyRecord() # 生成随机的code放入链接 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/active/{0}".format( code) # 使用django 内置函数完成邮件发送,四个参数:主题,邮件内容,发件人邮箱地址,收件人(字符串列表) 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/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() code = random_captcha() #验证码 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/active/{0}'.format( code) #可以返回一个状态码 status = send_mail(subject=email_title, message=email_body, from_email=EMAIL_HOST_USER, recipient_list=[email,], fail_silently=False) send_mail(subject=email_title, message=email_body, from_email=EMAIL_HOST_USER, recipient_list=[ email, ], fail_silently=False) elif send_type == 'forget': email_title = '溪枫教育密码重置链接' email_body = '请点击下面链接重置你的密码:http://127.0.0.1:8000/reset/{0}'.format( code) send_mail(subject=email_title, message=email_body, from_email=EMAIL_HOST_USER, recipient_list=[ email, ], fail_silently=False)
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() if send_type == "update_email": code = random_str(4) else: code = random_str(16) email_record.code = code email_record.email = email email_record.send_time = send_type email_record.save() email_title = "" email_body = "" if send_type == "register": email_title = "金宝贝在线注册激活链接" email_body = "请点击连接激活:http://127.0.0.1:8000/active/{0}".format() 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/reset/{0}".format() send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == "update_email": email_title = "金宝贝在线邮箱修改验证码" email_body = "你的邮箱验证码为:{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_mail(email, send_type='register'): email_record = EmailVerifyRecord() if send_type == "update_email": code = random_str(4) else: 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/active/{0}'.format(code) email_body = loader.render_to_string( "email_register.html", # 需要渲染的html模板 { "active_code": code # 参数 }) msg = EmailMessage(email_title, email_body, EMAIL_FROM, [email]) msg.content_subtype = "html" send_status = msg.send() # send_status = send_mail(email_title,email_body,EMAIL_FROM,[email]) if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() if send_type == 'update_email': code = random_str(4) else: code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == "register": email_title = '慕学在线网激活链接' email_body = '请点击下面的链接激活你的账号:http://127.0.0.1:8000/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/reset/{0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == 'update_email': email_title = '慕学在线网邮箱修改验证码' email_body = '你的邮箱验证码为:{0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() if send_type == 'update_email': code = random_str(4) else: 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 == "AddEmail": email_title = "问卷邮箱激活、添加链接" email_body = "请点击下面的链接激活你的邮箱: http://127.0.0.1:8000/users/active/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == 'ForPass': email_title = "问卷调查密码找回链接" email_body = "请点击下面的链接重置你的密码: http://127.0.0.1:8000/users/active/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def sendEmailToUser(emailaccount, sendtype): '''type 0 注册,type 1 忘记密码,type 2 修改邮箱''' code = crateRandomSeq() if sendtype == 2: code = crateRandomSeq()[0:4] email = emailaccount send_type = sendtype emailrecord = EmailVerifyRecord() emailrecord.code = code emailrecord.email = email emailrecord.send_type = send_type emailrecord.save() mailtitle = u"菜鸟在线教育注册激活链接" mailbody = u"请访问下面的地址激活您的账号: http://127.0.0.1:8000/activate/{0}".format( code) if sendtype == 0: send_status = send_mail(mailtitle, mailbody, EMAIL_HOST_USER, [email]) return send_status if sendtype == 1: mailtitle = u"菜鸟在线教育修改密码链接" mailbody = u"请访问下面的地址修改您的密码: http://127.0.0.1:8000/resetpwd/{0}".format( code) send_status = send_mail(mailtitle, mailbody, EMAIL_HOST_USER, [email]) return send_status if sendtype == 2: mailtitle = u"菜鸟教育修改邮箱验证码" mailbody = u"您的验证码为:{0}".format(code) send_status = send_mail(mailtitle, mailbody, EMAIL_HOST_USER, [email]) return send_status
def send_email(email, send_type): email_record = EmailVerifyRecord() if send_type == "update_email": code = random_str(4) else: code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == "register": email_title = u"在线点餐网激活链接" email_body = u"请点击下面链接激活你的账号:http://127.0.0.1:8000/active/{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass if send_type == "forget": email_title = u"在线点餐网修改密码链接" email_body = u"请点击下面链接修改你的密码:http://127.0.0.1:8000/reset/{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass if send_type == "update_email": email_title = u"在线点餐网修改邮箱验证码" email_body = u"您的邮箱验证码为: {0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == 'register': email_title = '慕雪在线网注册激活链接' # http://118.89.105.65 是我自己的服务器 IP 地址,你部署的时候,请换成你自己的 IP 或 域名 email_body = '请点击下面的链接激活你的账号:http://127.0.0.1:8000/active/{0}(如果是线上环境,请把 http://127.0.0.1:8000 替换成 http://118.89.105.65 )'.format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: # TODO print('发送成功') elif send_type == 'forget': email_title = '慕雪在线网密码重置链接' email_body = '请点击下面的链接重置你的密码:http://127.0.0.1:8000/reset/{0}(如果是线上环境,请把 http://127.0.0.1:8000 替换成 http://118.89.105.65 )'.format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: # TODO 提示发送成功 pass
def send_register_email(email, send_type): email_record = EmailVerifyRecord() 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 = "iMooc--STBoys 账户激活链接" email_body = "尊敬的用户:" \ " 感谢您注册使用iMooc在线教育平台,请点击以下链接激活您的账号:" \ "http://10.120.52.198:8000/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 = "iMooc--STBoys 密码重置链接" email_body = "尊敬的用户:" \ " 请点击一下链接重置您的密码:" \ "http://10.120.52.198:8000/reset/{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() 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/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/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == "update_email": email_title = "哈哈哈哈还想修改邮箱?" email_body = "请点击下面的链接激活你的账号: http://127.0.0.1:8000/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == 'register': email_title = '慕雪在线网注册激活链接' # http://118.89.105.65 是我自己的服务器 IP 地址,你部署的时候,请换成你自己的 IP 或 域名 email_body = '请点击下面的链接激活你的账号:http://127.0.0.1:8000/active/{0}(如果是线上环境,请把 http://127.0.0.1:8000 替换成 http://118.89.105.65 )'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: # TODO print('发送成功') elif send_type == 'forget': email_title = '慕雪在线网密码重置链接' email_body = '请点击下面的链接重置你的密码:http://127.0.0.1:8000/reset/{0}(如果是线上环境,请把 http://127.0.0.1:8000 替换成 http://118.89.105.65 )'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: # TODO 提示发送成功 pass
def send_email(email, send_type="register"): email_record = EmailVerifyRecord() 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 = u"新科技慕课网注册激活链接" email_body = u"请点击下面的链接激活你的账号: http://127.0.0.1:8000/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 = u"新科技慕课网密码重置链接" email_body = u"请点击下面的链接重置你的密码: http://127.0.0.1:8000/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_rigister_email(email,send_type='register'): email_record=EmailVerifyRecord() code=random_str(16) email_record.code=code email_record.email=email email_record.send_type=send_type email_record.save() email_title="" email_boby="" if send_type=="register": email_title="在线注册激活链接" email_boby="请点击下面链接激活你的账号:http://127.0.0.1:8000/active/{0}".format(code) send_status=send_mail(email_title,email_boby,EMAIL_FROM,[email]) if send_status: pass elif send_type=='forget': email_title = "在线注册密码重置链接" email_boby = "请点击下面链接激活你的账号:http://127.0.0.1:8000/reset/{0}".format(code) send_status = send_mail(email_title, email_boby, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() if send_type == 'update_email': code = random_str(4) else: 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/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/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == "update_email": email_title = "科创竞赛管理系统邮箱修改验证码" email_body = "你的邮箱验证码为: {0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() code = random_str(16) email_record.code = code email_record.email = email email_record.sen_type = send_type email_record.save() email_title = "" email_body = "" if send_type == "register": email_title = "在线网注册链接" email_body = "请点击下边的链接:http://127.0.0.1:8000/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/reset/{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() 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 = 'M视频在线网注册激活链接' email_body = '请点击下面的链接激活你的账号: http://127.0.0.1:8000/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 = 'M视频在线网密码重置链接' email_body = '请点击下面的链接重置你的账号密码: http://127.0.0.1:8000/reset/{0}'.format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() 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/active/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass if send_type == "forget": email_title = "找回密码链接" email_body = "请点击下面的链接找回你的密码: http://127.0.0.1:8000/reset/{0}".format( code) # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) # 如果发送成功 if send_status: pass
def send_register_email(email, send_type="register"): code = random_str(16) email_record = EmailVerifyRecord() 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 = u"mxonline在线激活链接" email_body = u"请点击下面的链接进行激活:http://127.0.0.1:8000/active/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass if send_type == 'forget': email_title = u"mxonline密码重置链接" email_body = u"请点击下面的链接进行密码重置:http://127.0.0.1:8000/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() if send_type == "update_email": code = random_str(4) else: code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == "register": email_title = "红蜻蜓教育网在线注册激活链接" email_body = "请点击以下链接激活账号:http://127.0.0.1:8000/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/reset/{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == "update_email": email_title = "红蜻蜓教育网在线邮箱修改链接" email_body = "你的验证码是:{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() if send_type == "update_email": code = random_str(4) else: code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == "register": email_title = "Online在线激活链接" email_body = "请点击下面的链接激活你的账号:http://127.0.0.1:8000/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 = "Online重置密码链接" email_body = "请点击下面的链接重置密码:http://127.0.0.1:8000/reset/{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == "update_email": email_title = "Online修改邮箱链接" email_body = "你的邮箱验证码为:{0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() # 邮箱验证码models code = random_str(16) # 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/active/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) # django提供的内部函数,用来发送邮件,发送成功返回true if send_status: pass elif send_type == "forget": email_title = "慕学在线网密码重置链接" email_body = "请点解下面的链接重置你的账号: http://127.0.0.1:8000/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) # django提供的内部函数,用来发送邮件,发送成功返回true if send_status: pass
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() if send_type == 'update_email': code = random_str(random_length=4) else: code = random_str(random_length=16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == 'register': email_title = '在线注册激活链接' email_body = '请点解链接:http://127.0.0.1:8000/active/{}/'.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/reset/{}/'.format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == 'update_email': email_title = '在线邮箱重置链接' email_body = '重置邮箱验证码:{} '.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() if send_type == 'update_email': code = random_str(4) else: 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 = u'mxOnline在线网注册激活链接' email_body = u'请点击下面的链接激活你的账号: http://localhost:8000/active/{0}'.format(code) send_status = send_mail(email_title, email_body, settings.EMAIL_FROM, [email]) if send_status: pass elif send_type == 'forget': email_title = u'mxOnline在线网密码重置链接' email_body = u'请点击下面的链接重置你的密码: http://localhost:8000/reset/{0}'.format(code) send_status = send_mail(email_title, email_body, settings.EMAIL_FROM, [email]) if send_status: pass elif send_type == 'update_email': email_title = u'mxOnline在线邮箱修改验证码' email_body = u'你的邮箱验证码为: {0}'.format(code) send_status = send_mail(email_title, email_body, settings.EMAIL_FROM, [email]) if send_status: pass
def send_email_register(email, send_type): email_recode = EmailVerifyRecord() if send_type == "update_email": random_str = generate_random_str(4) else: random_str = generate_random_str() email_recode.code = random_str email_recode.email = email email_recode.send_type = send_type email_recode.save() if send_type == "register": email_tittle = "hello注册" email_body = "验证码:{0}".format(random_str) send_status = send_mail(email_tittle, email_body, EMAIL_FROM, [email]) if send_status: print("yes") elif send_type == "forget": email_tittle = "hello找回密码" email_body = "验证码:{0}".format(random_str) send_status = send_mail(email_tittle, email_body, EMAIL_FROM, [email]) if send_status: print("yes") elif send_type == "update_email": email_tittle = "hello邮箱修改验证码" email_body = "您的验证码是:{0}".format(random_str) send_status = send_mail(email_tittle, email_body, EMAIL_FROM, [email]) if send_status: print("yes")
def send_register_email(email, send_type="register"): email_record = EmailVerifyRecord() if send_type == "update": code = random_str(4) else: code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == "register": email_title = "用户注册链接" email_body = "点击下面链接激活账号:http://127.0.0.1:8000/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/reset/{0}".format( code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == "update": email_title = "邮箱验证码" email_body = "您的邮箱验证码为: {0}".format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email,send_type ='register'): email_record = EmailVerifyRecord() code = random_str(6) email_record.code = code email_record.email = email email_record.send_type = send_type email_record.save() if send_type == 'register': email_title = 'VF视界注册激活连接' email_body = '点击连接激活你的账号:\nhttp://127.0.0.1:8000/active/{0}'.format(code) send_status = send_mail(email_title,email_body,EMAIL_FROM,[email]) if send_status: pass elif send_type == 'forgetpwd': email_title = 'VF视界网修改密码连接' email_body = '点击重置你的密码:\nhttp://127.0.0.1:8000/reset/{0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == 'update_email': email_title = 'VF视界重置邮箱验证码' email_body = '请保护好您的邮箱重置验证码:\n{0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() if send_type == 'email_update': code = random_str(4) else: 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/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/reset/{0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass elif send_type == 'email_update': email_title = '暮雪在线修改邮箱验证码' email_body = '邮箱验证码为: {0}'.format(code) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_type_email(email, send_type='register'): email_record = EmailVerifyRecord() if send_type == 'update_email': code = random_str(4) else: 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 = 'CodePedia注册激活链接' email_body = '请点击下面的链接激活你的账号: http://127.0.0.1:8000/users/active/{0}'.format( code) send_mail(email_title, email_body, EMAIL_FROM, [email]) elif send_type == 'forget': email_title = 'CodePedia密码重置链接' email_body = '请点击下面的链接重置你的账号: http://127.0.0.1:8000/users/reset/{0}'.format( code) send_mail(email_title, email_body, EMAIL_FROM, [email]) elif send_type == 'update_email': email_title = 'CodePedia邮箱修改链接' email_body = '你的邮箱验证码为{0}'.format(code) send_mail(email_title, email_body, EMAIL_FROM, [email])
def send_register_email(email, send_type="register"): # 将发送给用户的验证码(code)事先保存到数据库中 email_record = EmailVerifyRecord() 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/active/{0}".format( code) # 发送邮件,[email]指将邮箱发送给谁 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/reset/{0}".format( code) # 发送邮件,[email]指将邮箱发送给谁 send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) if send_status: pass
def send_register_email(email, send_type="register"): is_success = True # 发送之前先保存到数据库,到时候查询链接是否存在 # 实例化一个EmailVerifyRecord对象 email_record = EmailVerifyRecord() # 生成随机的code放入链接 code = random_str(16) email_record.code = code email_record.email = email email_record.send_type = send_type if send_type == "register": email_title = "注册激活" email_body = "请点击下面的链接激活你的账号: http://127.0.0.1:8000/active/{0}".format(code) # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,发件人邮箱地址,收件人(是一个字符串列表) send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) # 如果发送成功 if send_status: email_record.save() is_success = False elif send_type == "forget": email_title = "找回密码" email_body = "请点击下面的链接找回你的密码: http://127.0.0.1:8000/reset/{0}".format(code) # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) # 如果发送成功 if send_status: email_record.save() is_success = False elif send_type == "update_email": email_title = "变更邮箱验证码" email_body = "邮箱验证码为: {0}".format(code) # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) # 如果发送成功 if send_status: email_record.save() is_success = False return is_success
def send_register_email(email, send_type='register'): email_record = EmailVerifyRecord() if send_type == 'update_email': code = random_str(4) else: 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 = u"创客教育平台网注册激活链接" email_body = u"请点击下面的链接激活你的账号: http://127.0.0.1:8000/active/{0}".format(code) send_status = send_mail(email_title, email_body, DEFAULT_FROM_EMAIL, [email], fail_silently=False) if not send_status: pass elif send_type == 'forget': email_title = u"创客教育平台网重置密码链接" email_body = u"请点击下面的链接重置密码: http://127.0.0.1:8000/reset/{0}".format(code) send_status = send_mail(email_title, email_body, DEFAULT_FROM_EMAIL, [email], fail_silently=False) if not send_status: pass elif send_type == 'update_email': email_title = u"创客教育平台网邮箱修改验证码" email_body = u"你的邮箱验证码为:{0}".format(code) send_status = send_mail(email_title, email_body, DEFAULT_FROM_EMAIL, [email], fail_silently=False) if not send_status: pass
def send_register_eamil(email, send_type="register"): # 发送之前先保存到数据库,到时候查询链接是否存在 # 实例化一个EmailVerifyRecord对象 email_record = EmailVerifyRecord() # 生成随机的code放入链接 if send_type == "update_email": code = random_str(4) else: 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 = "CRM 注册激活链接" email_body = "欢迎注册CRM:请点击下面的链接激活你的账号: http://127.0.0.1:8000/active/{0}".format(code) # email_body = loader.render_to_string( # "email_register.html", # 需要渲染的html模板 # { # "active_code": code # 参数 # } # ) msg = EmailMessage(email_title, email_body, EMAIL_FROM, [email]) msg.content_subtype = "html" send_status = msg.send() # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list # send_status = send_mail(email_title, email_body, EMAIL_FROM, [email]) # 如果发送成功 if send_status: pass elif send_type == "forget": email_title = "CRM 找回密码链接" email_body = "欢迎注册CRM:请点击下面的链接重置你的账号密码: http://127.0.0.1:8000/reset/{0}".format(code) # email_body = loader.render_to_string( # "forgetpwd.html", # 需要渲染的html模板 # { # "active_code": code # 参数 # } # ) msg = EmailMessage(email_title, email_body, EMAIL_FROM, [email]) msg.content_subtype = "html" send_status = msg.send() elif send_type == "update_email": email_title = "mtianyan慕课小站 修改邮箱验证码" email_body = loader.render_to_string( "email_update_email.html", # 需要渲染的html模板 { "active_code": code # 参数 } ) msg = EmailMessage(email_title, email_body, EMAIL_FROM, [email]) msg.content_subtype = "html" send_status = msg.send()