A mail sending library for keg applications
Project description
Keg-Mail is a basic wrapper around Flask-Mail which gives some added support for templates.
It is not finished by any means and in some ways provides little additional benefit over Flask-Mail.
Usage
$ pip install keg-mail
Initialize Keg-Mail in you application
import flask
import keg_mail
from keg.signals import app_ready
from keg import Keg
bp = flask.blueprint('main', __name__)
mail = keg_mail.KegMail()
class App(Keg):
use_blueprints = [bp]
Initialize the extension with the application
@app_ready.connect
def init_extensions(app):
"""Init custom extensions used by this application"""
mail.init_app(app)
Define email content
import keg_mail
hello_world_content = keg_mail.EmailContent(
text='Hello {name}!'
html='<h1>Hello {name}!</h1>'
)
Send the email
from app import mail
import app.emails as emails
import keg_mail
bp.route('/')
def index():
mail.send(
'you@something.com'
keg_mail.Email(
subject="Hello {name}!",
content=emails.hello_world_content,
).format(name='You")
)
Test the email
from app import mail
def test_send_mail():
with mail.record_messages() as outbox:
resp = app.test_client.get('/')
assert len(outbox) == 1
assert outbox[0].subject == "Hello You!"
assert outbox[0].body == "Hello You!"
Changelog
0.2.3 released 2020-07-22
Handle timestamps parsed as decimals in Mailgun event JSON (6a03528)
0.2.2 released 2020-07-22
Fix bug in LogStatusWebhook view mixin (8a3ffde)
0.2.1 released 2020-07-22
Add support for Mailgun REST API and message status tracking (b3b4428)
0.2.0 released 2020-04-14
Support Python 3.8 (bfbb945)
0.1.0 - 2017-03-23
Initial Release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Keg-Mail-0.2.3.tar.gz
(15.1 kB
view hashes)
Built Distribution
Close
Hashes for Keg_Mail-0.2.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2965f0dcbca34e4180fe4d46ed7f0ee34fd13af35212745caeda66e853814db9 |
|
MD5 | e6e3f0cc1f2393b0d296632bcf3459bf |
|
BLAKE2b-256 | 545d43a589b2101865cda2fcb038c0485a9ba89287119890c8b2c63563cb84da |