def contact(): form = ContactForm() if form.validate_on_submit(): name = form.data['name'] mail = form.data['mail'] text = form.data['message'] html = render_template('message.html', content=text, name=name) subject = f'Notification from polls' SendingMails(app, mail).send_email(app.config['MAIL_USERNAME'], subject, html) flash('Your message was sent to administration. :)', 'success') return render_template('contact.html', form=form)
def contact(): form = ContactForm() if request.method == "POST" and form.validate_on_submit(): g = Gmail(delegated_user="******") msg = """ New Contact Form Submission: Name: {} Email: {} Message: {}""".format( form.name.data, form.email.data, form.message.data, ) g.send_email(to="*****@*****.**", subject="New Contact Submission", body=msg) return render_template("contact.html", form=form)