def contact(): form = ContactForm(request.form) if form.validate_on_submit(): email_body = render_template('general/email.txt', form=form) mail.send_message( sender=current_app.config['CONTACT_EMAIL_SENDER'], recipients=current_app.config['CONTACT_EMAIL_RECIPIENTS'], subject=current_app.config['CONTACT_EMAIL_SUBJECT'], body=email_body ) flash(u'Your message has been sent. I will get back to you as soon ' 'as possible.', 'success') return redirect(url_for('.index')) return render_template('general/contact.html', form=form)
def contact(): form = ContactForm(request.form) if form.validate_on_submit(): email_body = render_template('general/email.txt', form=form) from_email = u'{} <{}>'.format(form.name.data, form.email.data) mail.send_message( sender=from_email, recipients=current_app.config['CONTACT_EMAIL_RECIPIENTS'], reply_to=from_email, subject=current_app.config['CONTACT_EMAIL_SUBJECT'], body=email_body, extra_headers={'Sender': current_app.config['CONTACT_EMAIL_SENDER']} ) flash(u'Your message has been sent. I will get back to you as soon ' 'as possible.', 'success') return redirect(url_for('.index')) return render_template('general/contact.html', form=form)
def contact(): form = ContactForm(request.form) if form.validate_on_submit(): email_body = render_template('general/email.txt', form=form) from_email = u'{} <{}>'.format(form.name.data, form.email.data) extra_headers = { 'Sender': current_app.config['CONTACT_EMAIL_SENDER'], } mail.send_message( sender=from_email, recipients=current_app.config['CONTACT_EMAIL_RECIPIENTS'], reply_to=from_email, subject=current_app.config['CONTACT_EMAIL_SUBJECT'], body=email_body, extra_headers=extra_headers) flash( u'Your message has been sent. I will get back to you as soon ' 'as possible.', 'success') return redirect(url_for('.index')) return render_template('general/contact.html', form=form)