當前位置: 首頁>>代碼示例>>Python>>正文


Python Email.send_confirmation方法代碼示例

本文整理匯總了Python中models.Email.send_confirmation方法的典型用法代碼示例。如果您正苦於以下問題:Python Email.send_confirmation方法的具體用法?Python Email.send_confirmation怎麽用?Python Email.send_confirmation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Email的用法示例。


在下文中一共展示了Email.send_confirmation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: register

# 需要導入模塊: from models import Email [as 別名]
# 或者: from models.Email import send_confirmation [as 別名]
def register():
    if request.method == 'GET':
        return render_template('users/register.html')
    try:
        user = User(request.form['email'], request.form['password'])
        DB.session.add(user)
        DB.session.commit()
    except ValueError:
        DB.session.rollback()
        flash("%s is not a valid email address." % request.form['email'], "error")
        return render_template('users/register.html')
    except IntegrityError:
        DB.session.rollback()
        flash("An account with this email already exists.", "error")
        return render_template('users/register.html')

    login_user(user, remember=True)

    sent = Email.send_confirmation(user.email, user.id)
    res = redirect(request.args.get('next', url_for('account')))
    if sent:
        res.set_cookie('pending-emails', user.email, max_age=10800)
        flash("Your {SERVICE_NAME} account was created successfully!".format(**settings.__dict__), 'success')
        flash("We've sent an email confirmation to {addr}. Please go there and click on the confirmation link before you can use your {SERVICE_NAME} account.".format(addr=current_user.email, **settings.__dict__), 'info')
    else:
        flash("Your account was set up, but we couldn't send a verification email to your address, please try doing it again manually later.", "warning")
    return res
開發者ID:arun-shrestha,項目名稱:formspree,代碼行數:29,代碼來源:views.py

示例2: add_email

# 需要導入模塊: from models import Email [as 別名]
# 或者: from models.Email import send_confirmation [as 別名]
def add_email():
    address = request.form['address'].lower().strip()
    res = redirect(url_for('account'))

    g.log = g.log.bind(address=address, account=current_user.email)

    if Email.query.get([address, current_user.id]):
        g.log.info('Failed to add email to account. Already registered.')
        flash(u'{} is already registered for your account.'.format(
            address), 'warning')
        return res
    try:
        g.log.info('Adding new email address to account.')
        sent = Email.send_confirmation(address, current_user.id)
        if sent:
            pending = request.cookies.get('pending-emails', '').split(',')
            pending.append(address)
            res.set_cookie('pending-emails', ','.join(pending), max_age=10800)
            flash(u"We've sent a message with a verification link to {}."
                  .format(address), 'info')
        else:
            flash(u"We couldn't sent you the verification email at {}. "
                  "Please try again later.".format(
                    address), 'error')
    except ValueError:
        flash(u'{} is not a valid email address.'.format(
            request.form['address']), 'warning')
    return res
開發者ID:Amstutz-IT,項目名稱:formspree,代碼行數:30,代碼來源:views.py

示例3: add_email

# 需要導入模塊: from models import Email [as 別名]
# 或者: from models.Email import send_confirmation [as 別名]
def add_email():
    address = request.form['address']
    res = redirect(url_for('account'))

    if Email.query.get([address, current_user.id]):
        flash("%s is already registered for your account." % address, 'warning')
        return res
    try:
        sent = Email.send_confirmation(address, current_user.id)
        if sent:
            pending = request.cookies.get('pending-emails', '').split(',')
            pending.append(address)
            res.set_cookie('pending-emails', ','.join(pending), max_age=10800)
            flash("We've sent a message with a verification link to %s." % address, 'info')
        else:
            flash("We couldn't sent you the verification email at %s. Please "
                  "try again later." % address, "error")
    except ValueError:
        flash("%s is not a valid email address." % request.form['address'], "warning")
    return res
開發者ID:arun-shrestha,項目名稱:formspree,代碼行數:22,代碼來源:views.py


注:本文中的models.Email.send_confirmation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。