Exemplo n.º 1
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    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 = '注册激活链接'
        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
Exemplo n.º 2
0
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
Exemplo n.º 3
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 = '慕雪在线网注册激活链接'
        # 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
Exemplo n.º 4
0
def send_register_email(email, send_type=0):
    email_record = EmailVerifyRecord()
    if send_type == "update_email":
        code = generate_random_str(4)
    else:
        code = generate_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 = "Register activation"
        email_body = "Please click the following link to finish register: 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 = "Reset"
        email_body = "Please click the following link to reset password: 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 = "update_email"
        email_body = "Your verification code: {0}".format(code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 5
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_allard = ""
    if send_type == "register":
        email_title = "学友在线网注册激活链接"  # 邮件标题
        email_allard = "请点击下面链接激活你的账号:http://127.0.0.1:8000/active/{0}".format(
            code)  # 邮件正文内容
        # 向用户发送邮件
        send_status = send_mail(email_title, email_allard, EMAIL_FORM, [email])

        if send_status:
            pass
    elif send_type == "forget":
        email_title = "学友在线网密码重置连接"  # 邮件标题
        email_allard = "请点击下面链接激活你的账号:http://127.0.0.1:8000/reset/{0}".format(
            code)  # 邮件正文内容
        # 向用户发送邮件
        send_status = send_mail(email_title, email_allard, EMAIL_FORM, [email])
        if send_status:  # 测试是否发送成功,如果send_status为True说明已发送成功
            pass
    elif send_type == "update_email":
        email_title = "学友在线网邮箱修改验证码"  # 邮件标题
        email_allard = "你的邮箱验证码为:{0}".format(code)  # 邮件正文内容
        # 向用户发送邮件
        send_status = send_mail(email_title, email_allard, EMAIL_FORM, [email])
        if send_status:  # 测试是否发送成功,如果send_status为True说明已发送成功
            pass
Exemplo n.º 6
0
def send_register_email(email,send_type="register"):
    email_record=EmailVerifyRecord()
    code = generate_random_str(16)
    if send_type=="update_email":
        code=generate_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="请点击下面的链接你的账号: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)

        send_status=send_mail(email_title,email_body,EMAIL_FROM,[email])
        if send_status:
            pass

    if 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
Exemplo n.º 7
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/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
Exemplo n.º 8
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 = 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
Exemplo n.º 9
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()

    if send_type == 'register':
        email_title = "慕课网注册激活链接"
        email_body = "请点击下面的链接激活你的账号:http://127.0.0.1:8000/active/{0}".format(
            code)

        #需要去settings配置邮箱发送
        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)

        #需要去settings配置邮箱发送
        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)

        # 需要去settings配置邮箱发送
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 10
0
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()

    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
    elif send_type == "forget":
        email_title = "mxonline密码链接"
        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 = "mxonline修改邮箱"
        email_body = "请输入所给验证码: {0}".format(code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 11
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    # create the random verify code
    if send_type == "update":
        random_str = generate_random_str(4)
    else:
        random_str = generate_random_str(16)
    # Assign values to the model
    email_record.code = random_str
    email_record.email = email
    email_record.send_type = send_type
    email_record.save()

    email_title = ""
    email_body = ""
    # send the register verifying email
    if send_type == "register":
        email_title = "Activate your Mooc_Online Account"
        email_body = "Please click the below link to activate your account" \
                     "Mooc_Online account: http://127.0.0.1:8000/activate/{0}".format(random_str)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
    elif send_type == "forget":
        email_title = "Reset your Mooc_Online Password"
        email_body = "Please click the below link to reset your password " \
                     "Mooc_Online account: http://127.0.0.1:8000/reset/{0}".format(random_str)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
    elif send_type == "update":
        email_title = "Change your Mooc_Online Account Email"
        email_body = "This is your email update verify code:{0}".format(
            random_str)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 12
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 = 'ClassOnline 在线激活链接'
        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 = 'ClassOnline 密码重置链接'
        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 = 'ClassOnline邮箱修改验证码'
        email_body = '你的邮箱验证码为: {0}'.format(code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 13
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 = "LoveMooc在线网注册激活链接"
        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 = "LoveMooc在线网密码重置链接"
        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 = "LoveMooc修改邮箱验证码"
        email_body = "你的邮箱验证码为:{}".format(code)
        # 发送邮件
        send_status = send_mail(email_title,email_body,EMAIL_FROM,[email])
        if send_status:
            pass
Exemplo n.º 14
0
def send_email_code(email, send_type='register'):
    """
    发送邮箱验证码
    """
    email_code = EmailVerifyRecord()
    if send_type == 'update_email':
        random_str = generate_random_str(4)
    else:
        random_str = generate_random_str(16)
    email_code.email = email
    email_code.code = random_str
    email_code.send_type = send_type
    email_code.save()

    if send_type == 'register':
        email_title = '慕学在线网注册激活平台'
        email_body = '请点击下面的链接激活你的账号:http://127.0.0.1:8000/active/{0}'.format(random_str)

        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/resetpwd/{0}'.format(random_str)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass

    if send_type == 'update_email':
        email_title = '慕学在线网用户邮箱重置'
        email_body = '下面是你重置邮箱的验证码:{0}'.format(random_str)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 15
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 = 'mxonline register verification link'
        email_body = 'please click link below to activate your account: http://127.0.0.1:8000/active/{0}'.format(
            code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:  #发送成功为true
            pass

    elif send_type == "forget":
        email_title = 'password reset'
        email_body = 'please click link below to reset your password: http://127.0.0.1:8000/reset/{0}'.format(
            code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:  # 发送成功为true
            pass

    elif send_type == "update_email":
        email_title = 'email reset'
        email_body = 'code to reset your email: {0}'.format(code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:  # 发送成功为true
            pass
Exemplo n.º 16
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内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 17
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)

        sent_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if sent_status:
            pass
    elif send_type == "forget":
        email_title = "慕雪在线网重置密码"
        email_body = "请点击下面链接,重置你的密码:http://127.0.0.1:8000/reset/{0}".format(
            code)

        sent_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if sent_status:
            pass
    elif send_type == "update_email":
        email_title = "慕雪在线网修改邮箱"
        email_body = "你的邮箱验证码:{0}".format(code)

        sent_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if sent_status:
            pass
Exemplo n.º 18
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    if send_type == 'update_email':
        code = rand_str(6)
    else:
        code = rand_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, DEFAULT_FROM_EMAIL,
                                [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, DEFAULT_FROM_EMAIL,
                                [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, DEFAULT_FROM_EMAIL,
                                [email])
        if send_status:
            pass
Exemplo n.º 19
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    if send_type == "update_email":
        code = generate_random_str(4)
    else:
        code = generate_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
    elif send_type == 'update_email':
        email_title = '慕学在线网邮箱修改验证码'
        email_boby = '你的邮箱验证码为: {0}'.format(code)

        send_status = send_mail(email_title, email_boby, EMAIL_FROM, [email])
        if send_status:
            pass
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 = "NBA注册激活链接"
        email_body = "请点击下面的链接激活你的账号: http://127.0.0.1:8000/active/{0}".format(code)
        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,发件人邮箱地址,收件人(是一个字符串列表)
        send_status = send_mail(email_title, email_body, EMAIL_HOST_USER, [email])
        # 如果发送成功
        if send_status:
            pass
    elif send_type == 'forget':
        email_title = "NBA找回密码链接"
        email_body = "请点击下面的链接找回你的密码: http://127.0.0.1:8000/reset/{0}".format(code)
        # 使用Django内置函数完成邮件发送。四个参数:主题,邮件内容,从哪里发,接受者list
        send_status = send_mail(email_title, email_body, EMAIL_HOST_USER, [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_HOST_USER, [email])
        # 如果发送成功
        if send_status:
            pass
Exemplo n.º 21
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 = "bilibili在线网注册"
        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 = "bilibili在线网重置"
        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 = "bilibili在线网邮箱修改验证码"
        email_body = "你的邮箱验证码为:{0}".format(code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 22
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 = "Canysx注册激活链接"
        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:
            print("发送成功")
    elif send_type == "forget":
        email_title = "Canysx密码重置"
        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 = "Canysx验证码"
        email_body = "你的验证码为:{0}".format(code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 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
Exemplo n.º 24
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://www.wjj0315.top/active/{}'.format(code)

        send_status = send_mail(email_title, email_body, EMAIL_HOST_USER,
                                [email])
        if send_status:
            pass

    elif send_type == 'forget':
        email_title = '密码重置链接'
        email_body = '请点击链接重置密码:http://www.wjj0315.top/reset/{}'.format(code)
        send_status = send_mail(email_title, email_body, EMAIL_HOST_USER,
                                [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_HOST_USER,
                                [email])
        if send_status:
            pass
Exemplo n.º 25
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
Exemplo n.º 26
0
def send_register_email(email, send_type="register"):
    email_recod = EmailVerifyRecord()
    if send_type == "update_email":
        code = random_str(4)
    else:
        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 = "zkline在线注册激活"
        email_body = "请点击激活:http://127.0.0.1:8000/active/{0}".format(code)

        send_status = send_mail(email_title, email_body, DEFAULT_FROM_EMAIL,
                                [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, DEFAULT_FROM_EMAIL,
                                [email])
        if send_status:
            pass
    elif send_type == "updata_email":
        email_title == "邮箱修改验证码"
        email_body = "你的邮箱验证码为:{0}".format(code)
        send_status = send_mail(email_title, email_body, DEFAULT_FROM_EMAIL,
                                [email])
        if send_status:
            pass
Exemplo n.º 27
0
def send_register_email(email, send_type="register"):
    """
    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  # 将随机验证码存入邮箱验证表单中的验证码(code)类
    email_record.send_email = email
    email_record.send_type = send_type  # 看清楚models.py中send_type的相关类型
    email_record.save()

    if send_type == "register":
        email_title = "图说理工网用户激活链接"
        email_body = "请点击下面的链接激活你的账号:http://111.231.230.54/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://111.231.230.54/reset/{0}".format(
            code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 28
0
def send_register_email(email, send_type="register"):
    '''发送邮件给注册邮箱'''
    # 保存至数据库
    email_record = EmailVerifyRecord()
    code = generate_random_str(16)
    if send_type == "update_email":
        code = generate_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 = "请点击下面的链接激活你的账户:http://127.0.0.1:8000/users/activate/{0}".format(code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            print("ok")  # todo 在这里后续可以添加log日志

    elif send_type == "forget":
        email_title = "慕学在线网密码重置链接"
        email_body = "请点击下面的链接重置你的密码:http://127.0.0.1:8000/users/reset/{0}".format(code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            print("ok")

    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:
            print("ok")
Exemplo n.º 29
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    if send_type == 'update_email':
        code = generate_random_str(4)
    else:
        code = generate_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:8080/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:8080/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
Exemplo n.º 30
0
def send_register_email(email, send_type='register'):
    email_verify_record = EmailVerifyRecord()
    if send_type == 'update_email' or send_type == 'forget':
        code = random_str(4)
    else:
        code = random_str(16)
    email_verify_record.code = code
    email_verify_record.email = email
    email_verify_record.send_type = send_type
    email_verify_record.save()

    email_title = ''
    email_body = ''

    if send_type == 'register':
        email_title = u"MING's 个人博客 注册账号激活链接"
        email_body = u'请点击下方链接进行账号激活:http:23.106.145.108/users/activate/{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"MING's 个人博客 密码重置验证码"
        email_body = u'您好,你的邮箱验证码为{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 = u"MING's 个人博客 修改邮箱验证码"
        email_body = u'您好,你的邮箱验证码为{0}。如非本人操作,请忽略!!'.format(code)
        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 31
0
def send_register_email(email, send_type="register"):
    email_record = EmailVerifyRecord()
    code = base64.b64encode(uuid.uuid4().bytes)
    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/users/resetpwd/{0}".format(
            code)

        send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
        if send_status:
            pass
Exemplo n.º 32
0
def send_register_email(email, send_type='register'):
    email_record = EmailVerifyRecord()
    ran_str = random_str(20)
    email_record.email = email
    email_record.code = ran_str
    email_record.send_type = send_type
    email_record.save()

    if send_type == 'register':
        email_title = 'Zhiqi Travel 注册激活'
        email_body = '你好!\n' \
                     '感谢你注册Zhiqi Travel。 \n' \
                     '你的登录邮箱为:{0}。\n' \
                     '请点击下面的链接激活你的账号: \n' \
                     + DOMAIN_NAME + 'active/{1}'.format(email, ran_str)
        send_mail(email_title, email_body, EMAIL_FROM, [email])

    elif send_type == 'find':
        email_title = 'Zhiqi Travel 找回密码'
        email_body = '你好!\n' \
                     '你找回密码的邮箱为:{0}。\n' \
                     '请点击下面的链接找回你的密码: \n' \
                     + DOMAIN_NAME + 'find/{1}'.format(email, ran_str)
        send_mail(email_title, email_body, EMAIL_FROM, [email])
Exemplo n.º 33
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/{}".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
Exemplo n.º 34
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 = 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
Exemplo n.º 35
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 = "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()