def send_email(subject=None, recipients=[], html=''):
 plain_txt_email = 'Please view in a mail client that supports HTML.'
 if app.config.get('EMAILS_USE_SMTP'):
  try:
   with app.app_context():
    msg = Message(subject, recipients=recipients)
    msg.body = plain_txt_email
    msg.html = html
    mail.send(msg)
   app.logger.debug('Emailed {} - {} '.format(recipients, subject))
  except Exception as e:
   m = 'Failed to send failure message with subject: {}\n{} {}'.format(subject, Exception, e)
   app.logger.warn(m)
   app.logger.warn(traceback.format_exc())
 else:
  try:
   ses_region = app.config.get('SES_REGION', 'us-east-1')
   ses = boto.ses.connect_to_region(ses_region)
  except Exception as e:
   m = 'Failed to connect to ses using boto. Check your boto credentials. {} {}'.format(Exception, e)
   app.logger.warn(m)
   app.logger.warn(traceback.format_exc())
   return
  for email in recipients:
   try:
    ses.send_email(app.config.get('MAIL_DEFAULT_SENDER'), subject, html, email, format='html')
    app.logger.debug('Emailed {} - {} '.format(email, subject))
   except Exception as e:
    m = 'Failed to send failure message with subject: {}\n{} {}'.format(subject, Exception, e)
    app.logger.warn(m)
    app.logger.warn(traceback.format_exc())

def send_email ( subject = None , recipients = [ ] , html = '' ) : plain_txt_email = 'Please view in a mail client that supports HTML.' if app . config . get ( 'EMAILS_USE_SMTP' ) : try : with app . app_context ( ) : msg = Message ( subject , recipients = recipients ) msg . body = plain_txt_email msg . html = html mail . send ( msg ) app . logger . debug ( 'Emailed {} - {} ' . format ( recipients , subject ) ) except Exception as e : m = 'Failed to send failure message with subject: {}\n{} {}' . format ( subject , Exception , e ) app . logger . warn ( m ) app . logger . warn ( traceback . format_exc ( ) ) else : try : ses_region = app . config . get ( 'SES_REGION' , 'us-east-1' ) ses = boto . ses . connect_to_region ( ses_region ) except Exception as e : m = 'Failed to connect to ses using boto. Check your boto credentials. {} {}' . format ( Exception , e ) app . logger . warn ( m ) app . logger . warn ( traceback . format_exc ( ) ) return for email in recipients : try : ses . send_email ( app . config . get ( 'MAIL_DEFAULT_SENDER' ) , subject , html , email , format = 'html' ) app . logger . debug ( 'Emailed {} - {} ' . format ( email , subject ) ) except Exception as e : m = 'Failed to send failure message with subject: {}\n{} {}' . format ( subject , Exception , e ) app . logger . warn ( m ) app . logger . warn ( traceback . format_exc ( ) )
send email using backend specified in email_backend .