email.py 451 B

1234567891011121314
  1. from flask.ext.mail import Message
  2. from app import app, mail
  3. def send(recipient, subject, body):
  4. '''
  5. Send a mail to a recipient. The body is usually a rendered HTML template.
  6. The sender's credentials has been configured in the config.py file.
  7. '''
  8. sender = app.config['ADMINS'][0]
  9. message = Message(subject, sender=sender, recipients=[recipient])
  10. message.html = body
  11. with app.app_context():
  12. mail.send(message)