Python
Send your first message from a Python project with the official Postwick library.
Use this ready-made prompt to wire Postwick into your project
Add the Postwick Python SDK to this project, read POSTWICK_API_KEY from the environment and send a test email to delivered@postwick.dev.Prerequisites
Before you begin you need:
A Postwick API key
Guide
- Install
Add the library to your project.
pip install postwick - Store your API key
Keep the key out of source control by putting it in an environment variable.
.env POSTWICK_API_KEY=pw_live_4f9c2e7a1b - Send an email
The smallest useful call takes a sender, a recipient, a subject and a body.
main.py import os import postwick postwick.api_key = os.environ["POSTWICK_API_KEY"] email = postwick.Emails.send({ "from": "Lumen <hello@mail.lumen.dev>", "to": ["ada@example.com"], "subject": "Your receipt from Lumen", "html": "<p>Thanks for your order, Ada.</p>", }) print(email["id"])
Examples
Updated
Was this page helpful?