Пример #1
0
def send_register_email(email, type="register"):
    email_record = EmailVerifyRecord()
    random_str = generater_random_str(16)
    email_record.code = random_str
    email_record.email = email
    email_record.send_type = type
    email_record.save()

    email_title = ""
    email_body = ""

    if type == "register":
        email_title = "This is an active email:"
        email_body = "Please click this link to active your account : http://127.0.0.1:8000/active/{0}".format(
            random_str)
        email_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if email_status == True:
            pass

    if type == "forget":
        email_title = "This is finding password email:"
        email_body = "Please click this link to modify your password : http://127.0.0.1:8000/reset_password/{0}".format(
            random_str)
        email_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if email_status == True:
            pass
Пример #2
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    if send_type == 'update':
        code = generate_random_str(4)
    else:
        code = generate_random_str(4) + str(
            uuid.uuid1())  # random_str + uuid1 作为密码找回和邮箱激活
    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://192.168.206.182: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://192.168.206.182:8000/user/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
Пример #3
0
def send_register_email(email, send_type='register'):
    """
    发送注册邮件
    :param email: 接收方邮箱地址
    :param send_type: 类型
    :return:
    """
    email_record = EmailVerifyRecord()
    code = generate_random_str(16)
    email_record.code = code
    email_record.send_type = send_type
    email_record.email = email
    email_record.send_time = datetime.now()
    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
Пример #4
0
def send_email(email, send_type):
    email_record = EmailVerifyRecord()
    if send_type == 'update_email':
        code = random_str(4)
    else:
        code = random_str(4)
        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 = '验证码: \n{0}'.format(code)
        # email_title = '注册激活链接'
        # email_body = '请点击下面的链接激活你的账号: http://www.morain.top/novel/active/{0}'.format(code)
        send_status = send_mail(email_title,
                                email_body,
                                EMAIL_HOST_USER, [email],
                                fail_silently=False)
        if send_status:
            pass
    elif send_type == 'forget':
        email_title = '密码重置链接'
        email_body = '请点击下面的链接重置你的密码: http://www.morain.top/novel/reset/{0}'.format(
            code)

        send_status = send_mail(email_title, email_body, EMAIL_HOST_USER,
                                ['*****@*****.**'])
        if send_status:
            pass
Пример #5
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    if send_type == 'change':
        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 == 'change':
        email_title = '蒙咯咯咯 修改邮箱'
        email_body = '验证码{0}'.format(code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Пример #6
0
def send_register_eamil(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/jihuo/{0}".format(code)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,发件人邮箱地址,收件人(是一个字符串列表)
        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
Пример #7
0
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:8001/active/{0}'.format(
            code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
    else:
        email_title = '来自卢伟权的一封修改密码的邮件'
        email_body = '请点击下面的链接修改密码:http://127.0.0.1:8001/reset/{0}'.format(
            code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Пример #8
0
def send_register_email(email, send_type='register'):
    email_recod = EmailVerifyRecord()
    code = random_str(16)
    email_recod.code = code
    email_recod.email = email
    email_recod.send_type = send_type
    email_recod.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])
Пример #9
0
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 = '注册激活'
        email_body = '点击链接激活:http://127.0.0.1:8000/active/{0}'.format(code)
Пример #10
0
def send_regist_email(email, code_num=16, send_type='register'):
    # 发送之前先保存到数据库,到时候查询连接是否存在
    # 实例化一个EmailVerifyRecord()
    email_record = EmailVerifyRecord()
    # 生成随机字符串
    code = random_str(code_num)
    print(code)
    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://118.126.108.129/user/active/{0}/".format(
            code)

        # 使用Django内置函数完成邮件发送
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            print("邮件发送成功")
        else:
            print("发送失败")

    if send_type == "forget":
        email_title = "优课课堂邮箱验证"
        email_body = "请点击下面的链接重置你的账号: http://118.126.108.129//user/reset/{0}/".format(
            code)

        # 使用Django内置函数完成邮件发送
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
        else:
            print("发送失败")

    if send_type == "update_email":
        email_title = "优课课堂邮箱验证"
        email_body = "你的邮箱验证码是%s" % code

        # 使用Django内置函数完成邮件发送
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
        else:
            print("发送失败")
Пример #11
0
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 = "区块链音乐版权平台激活"
        email_body = "请点击下面的链接激活你的账号: http://127.0.0.1:8000/active/{0}".format(
            code)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        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)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        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)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass
Пример #12
0
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 = "TimeCat 注册激活链接"
        email_body = ("请点击下面的链接激活你的账号: " + EMAIL_ACTIVE_HOST +
                      "{0}").format(code)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass

    elif send_type == "forget":
        email_title = "TimeCat 找回密码链接"
        email_body = ("请点击下面的链接找回你的密码: " + EMAIL_RESET_HOST +
                      "{0}").format(code)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass

    elif send_type == "update_email":
        email_title = "NBA邮箱修改验证码"
        email_body = "你的邮箱验证码为{0}".format(code)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass
Пример #13
0
def send_register_email(email, send_type="register"):
    email_record = EmailVerifyRecord()  # 实例化一个对象来进行预处理
    # 邮箱重新绑定的验证码 目前设定为4位
    if send_type == 'update_email':
        code = random_string(4)
    else:
        code = random_string(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)
        # 邮件内容制作完成
        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        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)
        # 邮件内容制作完成
        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        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)
        # 邮件内容制作完成
        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM,
                                [email])  # 返回布尔值
        if send_status:
            pass
Пример #14
0
def send_register_email(email, send_type="register"):
    # 发送之前先保存到数据库,到时候查询链接是否存在
    # 实例化一个EmailVerifyRecord对象
    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)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        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)

        # 使用Django内置函数完成邮件发送。
        # 四个参数:主题,邮件内容,发件人邮箱地址,收件人(是一个字符串列表)
        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
Пример #15
0
def send_register_email(email,
                        send_type="register"):  #根据注册类型: 注册or找回密码来判断发哪种邮件
    email_record = EmailVerifyRecord(
    )  #每次发邮件记录都记录在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":  # 根据send_type定制发送内容
        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)
        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass

    elif send_type == "update_email":
        email_title = "NBA邮箱修改验证码"
        email_body = "你的邮箱验证码为{0}".format(code)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass
Пример #16
0
def send_register_email(code, 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()  #保存至数据库

    email_title = ''
    email_body = ''

    # if send_type == 'register':
    #     email_title = 'FreeStudy注册激活链接'
    #     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 == 'register':
        email_title = 'FreeStudy注册验证码'
        email_body = '你的FreeStudy账号注册验证码:{0}。有效期30分钟,请尽快输入。如非本人操作,请忽略本邮件'.format(
            code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            return send_status

    # if send_type == 'forget':
    #     email_title = 'FreeStudy密码重置链接'
    #     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

    if send_type == 'login':
        email_title = 'FreeStudy登陆验证码'
        email_body = '你的FreeStudy账号登陆验证码:{0}。有效期15分钟,请尽快输入。如非本人操作,请忽略本邮件'.format(
            code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            return send_status
Пример #17
0
def send_type_email(email, send_type="register"):
    email_record = EmailVerifyRecord()
    code = random_str(16)

    email_record.email = email
    email_record.code = code
    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)
    elif send_type == "forget":
        email_title = "找回密码邮件"
        email_body = "请点击链接更改你的账户密码:http://127.0.0.1:8000/reset/{0}".format(
            code)

    return send_email(email_title, email_body, email)
Пример #18
0
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 = 'MxOnline注册激活链接'
        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 = "MxOnline找回密码链接"
        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

    if send_type == "update_email":
        email_title = "MxOnline修改邮箱验证码"
        email_body = "你的邮箱验证码为{0}".format(code)

        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass
Пример #19
0
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.email = email
    email_record.code = code
    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:5212/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:5212/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
Пример #20
0
def my_send_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    email_record.email = email
    code = random_str(16)
    email_record.code = code
    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:5000/active/{0}/'.format(
            code)
    elif send_type == 'forget':
        email_title = u'乐学在线教育网密码重置链接'
        email_body = u'请点击下面的链接来重置你的密码:http://127.0.0.1:5000/reset_pwd/{0}/'.format(
            code)

    send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
    if send_status:
        pass
Пример #21
0
def send_register_email(email,username,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.username = username
    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/users/active/?username={0}&code={1}".format(urllib.parse.quote(username),code)

        send_status = send_mail(email_title, email_body, settings.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, settings.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, settings.EMAIL_FROM, [email])
        if send_status:
            pass
Пример #22
0
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

    if send_type == 'forget':
        email_title = "北极贝在线教育找回密码链接"
        email_body = "请点击下面的链接找回你的密码: http://127.0.0.1:8000/reset/{0}".format(
            code)

        # 使用Django内置函数完成邮件发送
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        # 如果发送成功
        if send_status:
            pass
Пример #23
0
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
Пример #24
0
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 = '慕学在线网注册激活链接'
        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:
            # TODO
            print('发送成功')

    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:
            # TODO 提示发送成功
            pass