flask-pystmark

Flask extension for Pystmark

MIT License

Downloads
73
Stars
8
Committers
2

Flask-Pystmark

Flask extension for Pystmark, a Postmark API library.

Flask-Pystmark supports Python 2.7, 3.6 and PyPy.

Read the complete docs

To run the tests, do python setup.py test

Example:

# app.py
from flask import Flask
from flask_pystmark import Pystmark, Message
from pystmark import ResponseError

app = Flask(__name__)
app.config['PYSTMARK_API_KEY'] = 'your_api_key'
app.config['PYSTMARK_DEFAULT_SENDER'] = '[email protected]'
pystmark = Pystmark(app)

@app.route('/')
def send():
    m = Message(to='[email protected]', text='Welcome')
    resp = pystmark.send(m)
    try:
        resp.raise_for_status()
    except ResponseError as e:
        return 'Failed to send message. Reason: {}'.format(e)
    else:
        return 'Sent message to {}'.format(resp.message.to)