langchain-sendmux
LangChain toolkit for Sendmux, the email API for AI agents.
Gives an agent its own mailbox: it can send email, read what arrives, and reply from its own address.
Requirements
- Python 3.10 or newer
langchain-corev1
Installation
pip install langchain-sendmux
Getting an API key
The toolkit needs a key that can both send and receive. Two ways to get one:
- Dashboard — create a mailbox and a mailbox-scoped key (
smx_mbx_*). See API keys. - Agent self-registration — the agent claims its own
@myagent.mxmailbox and gets ansmx_agent_*token, with no human signup first. See email for AI agents.
Note on agent tokens: a freshly self-registered smx_agent_* token can read and receive, but cannot send until a human owner has been invited and has approved it. Until then send_email and reply will fail. A dashboard smx_mbx_* key with send permission works immediately.
Read the key from the environment. Never hard-code it.
Quick start
import os
from langchain.agents import create_agent
from langchain_sendmux import SendmuxToolkit
smx = SendmuxToolkit(
api_key=os.environ["SENDMUX_API_KEY"],
default_from="agent@yourdomain.dev",
)
agent = create_agent(
model="gpt-4o",
tools=smx.get_tools(),
system_prompt="You triage the support inbox.",
)
agent.invoke(
{"messages": [{"role": "user", "content": "Reply to anyone asking about pricing."}]}
)
Tools
SendmuxToolkit(...).get_tools() returns three tools.
send_email
Sends through your configured sending providers, to any recipient.
| Parameter | Type | Required | Notes |
|---|---|---|---|
to |
str | yes | Recipient email address |
subject |
str | yes | Subject line |
text |
str | yes | Plain-text body |
html |
str | no | HTML body. Generated from text if omitted |
var_from |
str | no | Sender address. Falls back to default_from |
idempotency_key |
str | no | Makes a retried send idempotent for 24 hours |
var_from is spelt that way because from is a reserved word in Python.
list_messages
Lists messages in the agent's own mailbox, newest first.
| Parameter | Type | Required | Notes |
|---|---|---|---|
limit |
int | no | How many to return, 1 to 100. Defaults to 25 |
reply
Sends from the agent's own mailbox address, rather than through a sending provider. Use this to answer someone who wrote in.
| Parameter | Type | Required | Notes |
|---|---|---|---|
to |
str | yes | Recipient email address |
subject |
str | yes | Subject line |
text |
str | yes | Plain-text body |
html |
str | no | HTML body. Generated from text if omitted |
idempotency_key |
str | no | Makes a retried send idempotent for 24 hours |
Configuration
SendmuxToolkit(api_key=..., default_from=...)
| Option | Required | Purpose |
|---|---|---|
api_key |
yes | A send + receive mailbox key (smx_mbx_*) or a scoped agent token (smx_agent_*) |
default_from |
no | Default sender for send_email. Without it, the model has to supply var_from on every call |
Retries and duplicate sends
Agents retry. Pass idempotency_key on send_email and reply and Sendmux will send once, even if the same call arrives several times inside 24 hours. Any stable string works — a task id, a thread id, a hash of the message.
Details: idempotency.
Common errors
| What you see | Why | Fix |
|---|---|---|
ValueError: No sender address |
No var_from on the call and no default_from set |
Set default_from, or have the model pass var_from |
| Send rejected on an agent token | The token is self-registered and not yet owner-approved | Complete the owner invite and approval |
| Auth failure | Key lacks send or receive permission | Check the key's scope in the dashboard |
Related
- Quickstart
- Mailboxes
- All Sendmux SDKs
- Pricing — usage-based, no per-seat or per-mailbox fees
Licence
MIT. See the licence file.
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 langchain_sendmux-0.2.1.tar.gz.
File metadata
- Download URL: langchain_sendmux-0.2.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b1fcba03b777097bb936c47dfc337f4d93500db937c31febf6c49e3228fe64e
|
|
| MD5 |
97e8a795b7c546e7694e4b5a7c053ff4
|
|
| BLAKE2b-256 |
10fc9f8bd22188720f8813a26073a60b4e5c9b31dd57d8b3aa9b44be47186326
|
Provenance
The following attestation bundles were made for langchain_sendmux-0.2.1.tar.gz:
Publisher:
release-please.yml on Sendmux/sendmux-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_sendmux-0.2.1.tar.gz -
Subject digest:
7b1fcba03b777097bb936c47dfc337f4d93500db937c31febf6c49e3228fe64e - Sigstore transparency entry: 2366506731
- Sigstore integration time:
-
Permalink:
Sendmux/sendmux-sdk@d1ba3f4cd2d8b77cb9d28e77216acd8fb8eff14f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sendmux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@d1ba3f4cd2d8b77cb9d28e77216acd8fb8eff14f -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_sendmux-0.2.1-py3-none-any.whl.
File metadata
- Download URL: langchain_sendmux-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba7730767b7c2d79ebbfd66860d222a0293913225c6eca28b4028526f5bf2757
|
|
| MD5 |
f8a9a00ffa0d2224800d1bd3069dc903
|
|
| BLAKE2b-256 |
9abfa77ceba865be9c8c0698cd9d6b31b39a657f14237b874abf5aaef99316e0
|
Provenance
The following attestation bundles were made for langchain_sendmux-0.2.1-py3-none-any.whl:
Publisher:
release-please.yml on Sendmux/sendmux-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_sendmux-0.2.1-py3-none-any.whl -
Subject digest:
ba7730767b7c2d79ebbfd66860d222a0293913225c6eca28b4028526f5bf2757 - Sigstore transparency entry: 2366507378
- Sigstore integration time:
-
Permalink:
Sendmux/sendmux-sdk@d1ba3f4cd2d8b77cb9d28e77216acd8fb8eff14f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sendmux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@d1ba3f4cd2d8b77cb9d28e77216acd8fb8eff14f -
Trigger Event:
push
-
Statement type: