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.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.0.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file Keg-Mail-0.2.0.tar.gz
.
File metadata
- Download URL: Keg-Mail-0.2.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48144d4c3bf2bf14588adfca5a6c7d0d48191226526f2443780b06b164c21396 |
|
MD5 | 72fa49c80f1307b1e611021a1277b696 |
|
BLAKE2b-256 | fe0bdc0a50ceaa5a79898d2e813b29d853debb568907d94a6edf088a6fb27678 |
Provenance
File details
Details for the file Keg_Mail-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: Keg_Mail-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12e4962c13da67c8c2d6761771ca185f0ae498a00c8d70eee0b1c6d02984646b |
|
MD5 | ac5e3dbd5eb1775706add858101a4e14 |
|
BLAKE2b-256 | 64581fbfe62522e625146d31747aedb033ee302e3b1ae372f5e8360dd65e0a47 |