def contact(): form = HelpDeskForm() if request.method == 'POST': if form.validate() == False: flash('All fields are required.') return render_template('contact.html', form=form) else: msg = Message( form.Subject.data, sender='*****@*****.**', recipients=[ '*****@*****.**' ]) msg.body = """ From: %s <%s> %s """ % (form.Name.data, form.Email.data, form.Message.data) mail.send(msg) flash( 'Thank you for your message! We will get back to you shortly', category='success') return redirect(url_for('main.contact')) return render_template('contact.html', success=True, form=form) elif request.method == 'GET': return render_template('contact.html', form=form)
def send_email2(to, subject, body): msg = Message( subject, sender='[email protected] ', recipients=[to] ) msg.body = body mail.send(msg)
def send_email(to, subject, body): msg = Message( subject, sender=current_app.config['MAIL_USERNAME'], recipients=[to] ) msg.body = body mail.send(msg)
def send_email(subject, sender, recipients, text_body, html_body): """ Helper for sending specific emails """ msg = Message(subject, sender=sender, recipients=recipients) msg.body = text_body msg.html = html_body try: mail.send(msg) except Exception as exc: app.logger.debug("Error sending email [{}] to [{}] due: {}" .format(subject, recipients, exc)) raise
def send_email(subject, sender, recipients, text_body, html_body): """ Helper for sending specific emails """ msg = Message(subject, sender=sender, recipients=recipients) msg.body = text_body msg.html = html_body try: mail.send(msg) except Exception as exc: app.logger.debug("Error sending email [{}] to [{}] due: {}".format( subject, recipients, exc)) raise
def send_async_email(app, msg): with app.app_context(): mail.send(msg)
def send_mail(recp, title, message): message = Message(subject=title, body=message, recipients=recp) mail.send(message)