def send_mail(to_addr, mail, mimetype='plain', from_addr=None, mailer=None, username=None, password=None, callback=None, **context):
 from_addr = (from_addr or settings.FROM_EMAIL)
 mailer = (mailer or tasks.send_email)
 subject = mail.subject(**context)
 message = (mail.text(**context) if (mimetype in ('plain', 'txt')) else mail.html(**context))
 ttls = login = (not settings.DEBUG_MODE)
 logger.debug('Sending email...')
 logger.debug(u'To: {to_addr}\nFrom: {from_addr}\nSubject: {subject}\nMessage: {message}'.format(**locals()))
 kwargs = dict(from_addr=from_addr, to_addr=to_addr, subject=subject, message=message, mimetype=mimetype, ttls=ttls, login=login, username=username, password=password, categories=mail.categories)
 if settings.USE_EMAIL:
  if settings.USE_CELERY:
   return mailer.apply_async(kwargs=kwargs, link=callback)
  else:
   ret = mailer(**kwargs)
   if callback:
    callback()
   return ret

def send_mail ( to_addr , mail , mimetype = 'plain' , from_addr = None , mailer = None , username = None , password = None , callback = None , ** context ) : from_addr = ( from_addr or settings . FROM_EMAIL ) mailer = ( mailer or tasks . send_email ) subject = mail . subject ( ** context ) message = ( mail . text ( ** context ) if ( mimetype in ( 'plain' , 'txt' ) ) else mail . html ( ** context ) ) ttls = login = ( not settings . DEBUG_MODE ) logger . debug ( 'Sending email...' ) logger . debug ( u'To: {to_addr}\nFrom: {from_addr}\nSubject: {subject}\nMessage: {message}' . format ( ** locals ( ) ) ) kwargs = dict ( from_addr = from_addr , to_addr = to_addr , subject = subject , message = message , mimetype = mimetype , ttls = ttls , login = login , username = username , password = password , categories = mail . categories ) if settings . USE_EMAIL : if settings . USE_CELERY : return mailer . apply_async ( kwargs = kwargs , link = callback ) else : ret = mailer ( ** kwargs ) if callback : callback ( ) return ret
send an email via the flask-mail extension .