Send and receive emails with crypto micropayments via x402
Project description
x402mail
Send and receive emails with crypto micropayments. No accounts, no API keys — just a wallet.
Built on the x402 protocol — every API call is paid with USDC on Base via HTTP 402.
Install
pip install x402mail
Quick Start
from x402mail import X402Mail
mail = X402Mail(private_key="0x...")
# Send an email ($0.005 USDC)
result = mail.send(
to="alice@example.com",
subject="Hello from web3",
body="Sent via x402 micropayment!"
)
print(result)
# {"message_id": "abc-123", "inbox": "inbox-0x1a2b...@x402mail.com"}
# Check your inbox ($0.001)
inbox = mail.inbox()
# {"inbox": "inbox-0x1a2b...@x402mail.com", "total": 5, "unread": 2}
# List messages ($0.002)
messages = mail.messages(limit=5, unread_only=True)
# Read a message ($0.001)
msg = mail.read(message_id=1)
print(msg["body"])
MCP Server for AI Agents
Run a local MCP server so LLMs (Claude, GPT, etc.) can send and receive emails:
x402mail mcp
Claude Desktop / Cursor / Claude Code
Add to your MCP config:
{
"mcpServers": {
"x402mail": {
"command": "uvx",
"args": ["x402mail", "mcp"],
"env": {
"X402MAIL_PRIVATE_KEY": "0x..."
}
}
}
}
Or if you installed it with pip:
{
"mcpServers": {
"x402mail": {
"command": "x402mail",
"args": ["mcp"],
"env": {
"X402MAIL_PRIVATE_KEY": "0x..."
}
}
}
}
MCP Tools
| Tool | Cost | Description |
|---|---|---|
send_email |
$0.005 | Send an email to any address |
get_inbox |
$0.001 | Get your inbox address and message counts |
list_messages |
$0.002 | List inbox messages |
read_message |
$0.001 | Read a specific message |
How It Works
- You provide your Ethereum private key (for signing payments)
- Each API call is paid via x402 micropayments in USDC on Base
- Your wallet address = your identity — no accounts needed
- Your inbox is derived from your wallet:
inbox-{wallet}@x402mail.com
You → x402mail SDK → x402mail.com API
↓
402 Payment Required
↓
SDK auto-signs USDC payment
↓
Email sent ✓
Pricing
All prices in USDC on Base mainnet.
| Action | Cost |
|---|---|
| Send email | $0.005 |
| Check inbox | $0.001 |
| List messages | $0.002 |
| Read message | $0.001 |
$1 USDC covers ~200 emails.
Requirements
- Python 3.10+
- An Ethereum wallet with USDC on Base
Links
License
MIT
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 x402mail-0.2.0.tar.gz.
File metadata
- Download URL: x402mail-0.2.0.tar.gz
- Upload date:
- Size: 169.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13607c18856e024d8fc51e9f375fff7ceba11ca9e1288378f7d0328ebe121b65
|
|
| MD5 |
9e4603d158946d3337da6e0fa8e45928
|
|
| BLAKE2b-256 |
75bc9c39de88832293533165b01cc50323e300bd35e11e51aa3829e96db32830
|
File details
Details for the file x402mail-0.2.0-py3-none-any.whl.
File metadata
- Download URL: x402mail-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7aaa8c06620c389963bfd1c522ea9eb493a6cad74a64c8d76e97cb39d10028e
|
|
| MD5 |
c715caa1f53ad3b1a1af047aeeceb1a9
|
|
| BLAKE2b-256 |
851dd401a18d06c12da5efc0e9d2d10ac127747a7e847e7b9007d3e69fead134
|