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.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.1.tar.gz
(14.7 kB
view details)
Built Distribution
File details
Details for the file Keg-Mail-0.2.1.tar.gz
.
File metadata
- Download URL: Keg-Mail-0.2.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 083fb2856b004b6272df68fca60377a4c7f791652b44841a8f5e8b5e392f47a1 |
|
MD5 | d995606decf4746ca3a33422256348e9 |
|
BLAKE2b-256 | 30247a9a4c664fcb9e148b9aefc00e591198d57d91023f20a5a318aca64f8770 |
Provenance
File details
Details for the file Keg_Mail-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: Keg_Mail-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8abb5c806ebb2ef8ca238180b9c2c763c62076146a6756aa278cc960a67923fd |
|
MD5 | 275491a55e222fd9072a19ff740caf39 |
|
BLAKE2b-256 | 206b8fc5c5c983745ca1161d14ed949395257186612146782d132026db80a622 |