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.1.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.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: x402mail-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 68faac32d31c46142373fa938a5b4765ad6dc33942eae7822b905a1ef830f9b1
MD5 20485c06b2ede01f4bc96c67c50053d3
BLAKE2b-256 752bc112aced1f14378e7993e30277fe76ed9ab3cc132519fc00d13b9f536ab1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: x402mail-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f34779ace862927d2123c2059e77ca0f0396a16a9718a9c6f8cf20bd0aa48608
MD5 77f0c1f2f5bd80f60a9617edd4b9d32c
BLAKE2b-256 08134b972b2466eb5b8c966fbc690dcc2c783fb5cbf2c225f0320e03e75e81d3

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