示例#1
0
def reset():
    form = EmailForm(request.form)
    if request.method == "POST" and form.validate():
        print('email for rest validated')
        try:
            user = db.session.query(User).filter(
                User.email == form.email.data).first()
            print(user)
        except Exception as e:
            print('Exception raised at rest password view', e)
            flash('Invalid email address!', 'error')
            return redirect(url_for('homepage'))
        if user:
            send_password_reset_email(user.email)
            flash('Please check your email for a password reset link.',
                  'success')
            confirmation = 'Please check your email for a password reset link.'
            print('succes')
            return render_template('reset_password.html',
                                   form=form,
                                   confirmation=confirmation)
        else:
            flash(
                'Your email address must be confirmed before attempting a password reset.',
                'error')
            error = 'Your email address must be confirmed before attempting a password reset.'
            return render_template('reset_password.html',
                                   form=form,
                                   error=error)

    return render_template('reset_password.html', form=form)
示例#2
0
def send_list():
    form = EmailForm()
    if request.method == 'GET':
        return render_template('send_list.html', form=form)
    else:
        email_body = ""
        for value in my_list.values():
            email_body += f"""
        <h3>{value['app']}</h3>
        <p><strong>Distro:</strong> {value['distro']}.
        <br>
        <strong>Download URL (if available):</strong>{value['url']}.
        <br>
        <strong>Instruction:</strong>{value['instruction']}.
        <br>
        <strong>Command:</strong>{value['command']}
        <hr>
        """
        message = Mail(from_email='*****@*****.**',
                       to_emails=form.email_address.data,
                       subject="Commands from Linux Command Generator",
                       html_content=email_body)
        try:
            sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
            response = sg.send(message)
            print(response.status_code)
            print(response.body)
            print(response.headers)
            flash('Email sent', 'success')
            return redirect(request.referrer)
        except Exception as e:
            flash(f'{e}')
            return redirect(request.referrer)
示例#3
0
def sendmail(request):
	if request.method == 'POST':
		form = EmailForm(request.POST)
		if form.is_valid():
			email = form.cleaned_data['email']
			subject = form.cleaned_data['subject']
			message = form.cleaned_data['message']
			try:
				send_mail(subject, message, email, ['*****@*****.**'])
				return HttpResponseRedirect('/email/ok/')
			except:
				return HttpResponseRedirect('/email/ko/')
		else:
			return HttpResponseRedirect('/email/invalid/')
	else:
		return HttpResponseRedirect('/email/')  
示例#4
0
def send_email():
    form = EmailForm()
    if request.method == 'POST':
        if not form.validate_on_submit():
            return
        username = session.get('username', 'null')
        title = form.title.data
        content = form.content.data
        new_title = '%s--%s' % (username, title)
        msg = Message(new_title,
                      sender='*****@*****.**',
                      recipients=['*****@*****.**'])
        msg.body = content
        flash('发送成功!')
        thread = Thread(target=send_async_email, args=[app, msg])
        thread.start()

    return render_template('datas/send_email.html', form=form)
示例#5
0
def forgot():
    if current_user.is_authenticated:
        return redirect(url_for('index'))

    form = EmailForm()
    if form.validate_on_submit():
        customer = Customer.query.filter_by(email=form.email.data).first()
        if customer is None:
            flash('There is no Account with this email. Please Register.',
                  'warning')
            return redirect(url_for('forgot'))
        user = User.query.filter_by(id=customer.id).first()
        reset_email(user)
        flash(
            'An email has been sent with instructions to reset your password.',
            'success')
        return redirect(url_for('login'))
    return render_template('reset_request.html', form=form)
示例#6
0
文件: app.py 项目: LabLeon/flask-101
def index():
    form = EmailForm(request.form)
    flag = False

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
        if form.email.data is not None:
            print(f"Email capturado: {form.email.data}")
            flag = True

    return render_template('index.html', flag=flag)
示例#7
0
def compratarjeta():
    form = EmailForm(request.form)
    no_data = False

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
        if form.nombrecompleto.data is not None:
            #print(f"Nombre capturado: {form.nombrecompleto.data}")
            flag = True
            return render_template('finalcompra.html',
                                   nombrecompleto=form.nombrecompleto.data)
        else:
            no_data = True
    return render_template('compratarjeta.html', no_data=no_data)
示例#8
0
def index():
    form = EmailForm(request.form)
    flag = False
    name = None

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
        email = form.email.data
        name = form.name.data
        if email != '' and name != '':
            print(f"Nombre capturado: {name}")
            print(f"Email capturado: {email}")
            flag = True

    return render_template('index.html', flag=flag, name=name)
示例#9
0
def index():
    form = EmailForm(request.form)
    flag = False
    name = None

    if len(form.errors):
        print(form.errors)
    if request.method == 'POST':
        email = form.email.data
        name = form.name.data
        if email != '' and name != '':
            print(f"Nombre capturado: {name}")
            print(f"Email capturado: {email}")
            user = {"name": name, "email": email}
            r = db_insert_user(users, user)
            print("Inserción:", r)
            flag = True

    return render_template('index.html', flag=flag, name=name)