Пример #1
0
def contact():
    contact_form = ContactForm()
    if contact_form.validate_on_submit():
        data = contact_form.data
        msg = Message("OperondemmoDB Contact", sender=sender, recipients=["*****@*****.**"])
        msg.body = "email:" + data["email"] + "\ncontent:" + data["text"]
        executor.submit(send_async_email, app, msg)
        # mail.send(msg)
        flash("send OK", "ok")
        return redirect(url_for("home.contact"))
    return render_template("home/contact.html", form=contact_form)
Пример #2
0
    def contact(self):
        form = ContactForm()

        if request.method == 'POST':
            if not form.validate_on_submit():
                flash('All fields are required.')
                return render_template('contact.html', form=form)

            send_email(form.email.data, form.subject.data, form.message.data)
            return render_template('contact.html', success=True)

        elif request.method == 'GET':
            return render_template('contact.html', form=form)