Official MailKite SDK for Python — send and manage email over your own authenticated domain.
Project description
MailKite for Python
Email for every product you ship — receive email as a webhook, send over a verified domain, give an AI agent its own inbox.
The official MailKite library for Python.
Docs · Library guide · mailkite.dev · AI agents
Read-only mirror. This repo is a generated, release-time mirror of the MailKite monorepo (the private source of truth) — development doesn't happen here. Install from PyPI and open issues against the MailKite docs.
Install
pip install mailkite-dev
Published as
mailkite-devwhile themailkitename is reclaimed — the import isfrom mailkite import MailKite.
Quickstart
import os
from mailkite import MailKite
mk = MailKite(os.environ["MAILKITE_API_KEY"])
res = mk.send({
"from": "hello@myapp.ai",
"to": "ada@example.com",
"subject": "Your invoice #1042",
"html": "<p>Thanks! Receipt attached.</p>",
})
Examples
Runnable examples live in examples/ — send mail, verify webhooks, build an AI email agent, and log users in:
| Example | What it shows |
|---|---|
examples/01_send_email.py |
Send an email over a verified domain — the 10-second "it works". |
examples/02_receive_webhook.py |
Receive inbound email as a webhook — and VERIFY the HMAC signature before trusting it. |
examples/03_agent_email_reply.py |
An AI email agent: inbound email → Claude drafts a reply → MailKite sends it, threaded. |
examples/04_give_your_agent_an_inbox.py |
Give your agent its own email address — MailKite's built-in inbox agent answers mail for… |
examples/05_server_login.py |
Server-side login + register. |
API methods
Every method is documented on its own page under docs/. The full surface:
| Method | What it does |
|---|---|
send |
Send a message over a verified domain. Pass templateId (+ optional templateData) to… |
uploadAttachment |
Upload a file to MailKite storage and get back a secure, time-limited URL. Reference the… |
listTemplates |
List your saved email templates (light metadata only — no body). Use getTemplate for the… |
listBaseTemplates |
List the premade base templates (light metadata). Clone one with createTemplate({ baseId… |
getTemplate |
Get one template (full: subject, html, text, theme). Works for your templates (tpl_…) and… |
createTemplate |
Create a template. Pass baseId to clone a base template into your own, or provide… |
listDomains |
List your domains, each with its webhook URL. |
createDomain |
Add a domain. Returns the domain + DNS records. |
getDomain |
Get one domain with DNS records + webhook. |
deleteDomain |
Remove a domain. |
verifyDomain |
Check DNS and update status. |
setWebhook |
Set or replace the domain's catch-all webhook. |
deleteWebhook |
Remove the domain's webhook. |
testWebhook |
Send a signed test event to the domain's webhook. |
checkDomainAvailability |
Check whether a domain is available to register, and at what price. Read-only — no charge. |
registerDomain |
Register (buy) a domain on the customer's behalf; provisions mail DNS and adds it to the… |
listRoutes |
List inbound routing rules. |
createRoute |
Create a route (match, action, destination). |
agent |
Send a message to one of your inbox agents and get its reply. Defaults to the account's… |
route |
Route a message to one of your registered routes (by routeId or address), running… |
listMessages |
List stored messages. |
getMessage |
Get a message with deliveries + attachments. |
retryDelivery |
Re-deliver a stored message to its webhook. |
listLists |
List your contact lists (static, curated broadcast audiences), each with its member count. |
createList |
Create a contact list. Returns the list with its id (lst_…); add contacts with… |
getList |
Get one contact list with its member count. |
updateList |
Rename a contact list. |
deleteList |
Delete a contact list. The list is removed; the contacts themselves are kept. |
listListContacts |
List the contacts that are members of a list. |
addListContacts |
Add contacts (by id, ctr_…) to a list. Returns how many were newly added; contacts… |
removeListContact |
Remove one contact from a list (the contact itself is kept). |
listBroadcasts |
List your broadcasts (one-to-many sends) with status and send stats. |
createBroadcast |
Create a broadcast draft. from is required; set audience to { type: "all" } or {… |
getBroadcast |
Get one broadcast with its status and recipient summary. |
updateBroadcast |
Edit a draft broadcast (any of from/subject/audience/html/… ). Drafts only. |
deleteBroadcast |
Delete a broadcast draft. |
sendBroadcast |
Send a broadcast now, or pass an ISO 8601 scheduledAt to schedule it. A one-click… |
verifyWebhook |
Verify the x-mailkite-signature header on an inbound webhook delivery. Runs entirely… |
replyOk |
The acknowledgement body a webhook consumer returns to confirm it processed the event —… |
replySpam |
Control-mode reply a webhook consumer returns to tell MailKite to mark the message as… |
replyDrop |
Control-mode reply a webhook consumer returns to tell MailKite to drop (discard) the… |
replyBlockSender |
Control-mode reply a webhook consumer returns to tell MailKite to block the sender — the… |
encrypt |
Encrypt a UTF-8 string to a domain's RSA public key (SPKI/PEM), returning the at-rest… |
decrypt |
Decrypt a MailKite at-rest envelope JSON with your RSA private key (PKCS8/PEM), returning… |
semanticSearch |
Semantic search over the MailKite documentation — returns the most relevant doc sections… |
Use it from an AI agent — MCP + Agent connectors
MailKite speaks the Model Context Protocol: every API method is a tool your AI assistant (Claude, Cursor, …) can call — send mail, manage domains, search the docs, and give an agent its own inbox. Full guide: https://mailkite.dev/docs/ai-agents.
Hosted (recommended) — one-click OAuth, no key to copy:
claude mcp add --transport http mailkite https://mcp.mailkite.dev/mcp
In Claude Code you can also install the plugin:
/plugin marketplace add mailkite/claude-code
/plugin install mailkite@mailkite
Any chat/UI agent: "Add the MCP server at https://mcp.mailkite.dev/mcp and authenticate in the browser when prompted."
Local (static key, offline / CI):
{ "mcpServers": { "mailkite": { "command": "npx", "args": ["-y", "@mailkite/mcp"], "env": { "MAILKITE_API_KEY": "mk_live_…" } } } }
Give an agent its own inbox. Route inbound mail to a built-in inbox agent (the agent route action) and it answers, files, or escalates on its own — see https://mailkite.dev/docs/ai-agents.
All MailKite libraries
Same contract, every language — pick the one for your stack (full list: https://mailkite.dev/docs/libraries):
| Library | Repo | Distribution |
|---|---|---|
| MailKite for Node.js | mailkite-node |
npm |
| MailKite for Python (this repo) | mailkite-python |
PyPI |
| MailKite for Ruby | mailkite-ruby |
RubyGems |
| MailKite for Java | mailkite-java |
Maven Central |
| MailKite for PHP | mailkite-php |
Packagist |
| MailKite for Go | mailkite-go |
Go modules |
| @mailkite/cli | mailkite-cli |
npm |
| @mailkite/mcp | mailkite-mcp |
npm |
| @mailkite/client | mailkite-js |
npm |
| @mailkite/expo | mailkite-expo |
npm |
| MailKiteClient | mailkite-swift |
Swift Package Manager |
| dev.mailkite:mailkite-client | mailkite-kotlin |
Maven Central |
| mailkite_client | mailkite-flutter |
pub.dev |
Docs & links
- 📚 Documentation: https://mailkite.dev/docs
- 📦 This library's guide: https://mailkite.dev/docs/libraries
- 🤖 AI agents (MCP + inbox agents): https://mailkite.dev/docs/ai-agents
- 🌐 Website: https://mailkite.dev
- 🧭 All libraries: https://mailkite.dev/docs/libraries
Generated from the shared MailKite API contract. © MailKite.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mailkite_dev-0.9.0.tar.gz.
File metadata
- Download URL: mailkite_dev-0.9.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbb69e90ee80de139eca84080de52cfebcee38299055c8b038b9f8f878d2fd27
|
|
| MD5 |
5d247dbac9894d14890ab746c7a63fc6
|
|
| BLAKE2b-256 |
de451fc8ae90dc717cc9c199d5dc17e84ea47b5246f731b1a2608afbb91b1a3b
|
File details
Details for the file mailkite_dev-0.9.0-py3-none-any.whl.
File metadata
- Download URL: mailkite_dev-0.9.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be7d5e540c51a6c0e1cf18d690b373376d32acd3ea8ac05ebf61c9d764d02e01
|
|
| MD5 |
1f27495fe23cfbd2802afe7fdb4f618b
|
|
| BLAKE2b-256 |
e991647f6bb4380f10bac1959291763e3a06eb115ccb5abaed750aef2a83143d
|