flask extension for delivering messages. send via the app engine mail or xmpp apis, and/or other third party providers such as sendgrid.
flask extension for delivering messages.
send via google app engine’s mail or xmpp
apis, and/or other third party providers such as
sendgrid.
install with pip:
pip install flask-telegram
setup from outside the flask app request context:
from flask.ext import telegram
# setup the jinja templates + environment..
from jinja2 import Environment, loaders
jinjaenv = Environment(loader=loaders.DictLoader({
"subject.html": "{{ var_subject }},"
"body.html": "<html>{{ var_html_body }}</html>,"
"body.text": "{{ var_text_body }},"
}))
# setup the template..
messagetemplate = telegram.MessageTemplate(
sender="[email protected]",
subject="subject.html",
body_html="body.html",
body_text="body.html",
jinja_env=jinjaenv)
# now let's assume you want to batch message recipients..
recipients = ["[email protected]", "[email protected]", "[email protected]"]
for recipient in recipients:
context = {
"var_subject": "telegram'd subject",
"var_html_body": "telegram'd html body",
"var_text_body": "telegram'd text body"}
message = telegram.Message(messagetemplate)
message.deliver(recipient=recipient, **context)
setup from within the flask app request context:
[todo]