Skip to main content

Lockally for Flask

Official Lockally extension for Flask. Send transactional email from any view with a small, idiomatic Lockally(app) extension.

Install

pip install lockally-flask

Configure

from flask import Flask
from lockally_flask import Lockally

app = Flask(__name__)
app.config["LOCKALLY_API_KEY"] = "lk_live_xxx"      # lk_test_xxx runs in sandbox
# app.config["LOCKALLY_BASE_URL"] = "https://api.lockally.com"   # optional override
lockally = Lockally(app)

The application-factory pattern is supported too:

lockally = Lockally()

def create_app():
    app = Flask(__name__)
    app.config["LOCKALLY_API_KEY"] = "lk_live_xxx"
    lockally.init_app(app)
    return app

Send

from lockally_flask import send_email

@app.post("/signup")
def signup():
    send_email(
        from_="alerts@yourdomain.com",
        to="user@example.com",
        subject="Welcome",
        text="Thanks for signing up.",
        html="<b>Thanks for signing up.</b>",
        reply_to="support@yourdomain.com",
        attachments=[("welcome.pdf", pdf_bytes, "application/pdf")],
    )
    return "", 202

send_email uses the client registered on the current app, so blueprints can call it without holding a reference. to/cc/bcc/reply_to accept a single address or a list; attachments is a list of (filename, content, content_type) (content is bytes or str).

Mapping notes

  • Reply-To is sent as a header (Lockally has no reply_to field).
  • Attachments are base64-encoded as {filename, content_type, content_base64}.
  • One Idempotency-Key is generated per send (24 h dedupe window).

License

MIT © Lockally

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lockally_flask-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lockally_flask-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file lockally_flask-0.1.0.tar.gz.

File metadata

  • Download URL: lockally_flask-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lockally_flask-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96cbf0147f170f20d51289a035daa98e12ac5935dc128e64fb457fa458a24a59
MD5 625e5262313247a40f5daa03ae6fa11a
BLAKE2b-256 b7542b832e1d0561e4fb8358c23b27219f41cb586fb34b34c0e422bfcf429262

See more details on using hashes here.

Provenance

The following attestation bundles were made for lockally_flask-0.1.0.tar.gz:

Publisher: publish.yml on LockallyInc/lockally-flask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lockally_flask-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lockally_flask-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lockally_flask-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 636852e92f2f0168ceda8af3e495308fa21f01eb72ee26f3f33425fe4341333c
MD5 3654dd830ecad6050981f5bba506ab91
BLAKE2b-256 d7280a1de15d3e2d162c3cffe2cd613a13468a7c36bc1895fed38f334f17a2ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for lockally_flask-0.1.0-py3-none-any.whl:

Publisher: publish.yml on LockallyInc/lockally-flask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page