Flask-MarrowMailer is a Flask extension that simplifies the use of marrow.mailer to send emails in Flask applications.

The following is a basic example that sends a test email when the route /send is accessed:

from flask import Flask from flask_marrowmailer import Mailer app = Flask ( __name__ ) mailer = Mailer ( app ) @app . route ( '/send' ) def send_email (): msg = mailer . new () msg . author = 'Sender <sender@localhost>' msg . to = [ 'user@example.com' ] msg . subject = 'test email' msg . plain = 'this is the text version' msg . rich = '<p>this is the <b>html</b> version</p>' mailer . send ( msg ) return "email sent!" app . run ( debug = True )

The message can also render the body from templates:

@app . route ( '/send' ) def send_email (): msg = mailer . new () msg . author = 'Sender <sender@localhost>' msg . to = [ 'user@example.com' ] msg . subject = 'test email' msg . render_template ( 'body.email' , user = 'david' ) mailer . send ( msg ) return "email sent!"