Skip to main content

A mail sending library for keg applications

Project description

Keg-Mail

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.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.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

Keg_Mail-0.1.0-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Keg-Mail-0.1.0.tar.gz.

File metadata

  • Download URL: Keg-Mail-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Keg-Mail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e71b0a0e4c0662afed70dfb8a080753af38c8c3a0c7006813ec5a6c66ebeb88
MD5 779e4707eccb1a53684c92d6268cd8bf
BLAKE2b-256 e710dd113dfb16db8fe57638ba23c0cca1569e78188c4b99f62d186d1f0f36a2

See more details on using hashes here.

Provenance

File details

Details for the file Keg_Mail-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Keg_Mail-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c78c7938176df3683dbded8fb21bacce9f0243cd04d8774b4b94402dc025f376
MD5 d25f7ab9c69ab38eccf1b40e77ab0ffa
BLAKE2b-256 573c6cd1caa892336cdd25b46e2088678ccad35a71838698199618aadef5c8d5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page