Skip to main content

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.

Install

pip install x402mail[cdp]

Quick Start

export CDP_API_KEY_ID="your-key-id"          # from cdp.coinbase.com
export CDP_API_KEY_SECRET="your-key-secret"
export CDP_WALLET_SECRET="your-wallet-secret"
from x402mail import X402Mail

mail = X402Mail.from_cdp()   # wallet created automatically
print(mail.address)          # fund this with USDC on Base

# Send an email ($0.005 USDC)
result = mail.send(
    to="alice@example.com",
    subject="Hello from x402mail",
    body="Sent with 3 lines of Python!"
)
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)
if messages:
    msg = mail.read(message_id=messages[0]["id"])
    print(msg["body"])

Or with a private key: X402Mail(private_key=os.getenv("EVM_PRIVATE_KEY"))

MCP Server for AI Agents

Run a local MCP server so LLMs (Claude, GPT, etc.) can send and receive emails:

x402mail mcp

Add to your MCP config (Claude Desktop / Cursor / Claude Code):

{
  "mcpServers": {
    "x402mail": {
      "command": "x402mail",
      "args": ["mcp"],
      "env": {
        "CDP_API_KEY_ID": "your-key-id",
        "CDP_API_KEY_SECRET": "your-key-secret",
        "CDP_WALLET_SECRET": "your-wallet-secret"
      }
    }
  }
}

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

Pricing

Action Cost
Send email $0.005
Check inbox $0.001
List messages $0.002
Read message $0.001

$1 USDC covers ~200 emails.

Wallet Setup

CDP Server Wallet (recommended): Follow the CDP quickstart guide to get API keys. No private keys to manage.

Private Key: Use any EVM wallet with USDC on Base. pip install x402mail (without [cdp]).

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

x402mail-0.2.4.tar.gz (169.6 kB view details)

Uploaded Source

Built Distribution

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

x402mail-0.2.4-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file x402mail-0.2.4.tar.gz.

File metadata

  • Download URL: x402mail-0.2.4.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

Hashes for x402mail-0.2.4.tar.gz
Algorithm Hash digest
SHA256 07b51f06cc6126bb6bc1f54fb2bbe515db502a5bf5fc1c5ab7636a6b056aea8c
MD5 e51c0d521c4685b4fc742142c82cce11
BLAKE2b-256 70d8abcd15afd64b5b18e27ca23c5130c57cf3407f90195310007f14aabb5828

See more details on using hashes here.

File details

Details for the file x402mail-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: x402mail-0.2.4-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

Hashes for x402mail-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bab6c25aae63c74805f939f776a5d1b17dffa006369c8740934a28710e7437be
MD5 a63a15892ba22ad320ef92df4f32b219
BLAKE2b-256 fea0bb4405c6ba29c92810baf065d96eb885ce18c3c079b2e934b16099ca93b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page