def send_test_template():
'''
Sends a test template to the provided address
'''
form = SendTestTemplateForm(request.form)
if form.validate_on_submit():
report = EmailReport.make_sample()
try:
subject = render_template_string(form.subject.data, report=report)
text = render_template_string(form.text.data, report=report)
email_provider.send(
to=form.recipient.data,
sender=g.user.email(),
subject=subject,
body=text)
return jsonify({'success': True, 'message': 'Sent test email.'})
except Exception as e:
return json_error(400, str(e), {})
return json_error(400, list_errors(form), {})
评论列表
文章目录