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

Uploaded Python 3

File details

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

File metadata

  • Download URL: x402mail-0.2.3.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.3.tar.gz
Algorithm Hash digest
SHA256 1a40ca93a7d228bb1c6ed6caeb51f02b92ebf896931607777e059601f5374d13
MD5 1efea754c53777078fef917030f8b1df
BLAKE2b-256 d96c1241ccde97ee6c0cddc72605cd88789ccd6717045fe150b8b24b7e99c03d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: x402mail-0.2.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c1c646e2fb7fde32293be17cb172daf5abdc54a719fda2e4615b499969c3a9bf
MD5 f5054a46b954744ba43a89112a17e450
BLAKE2b-256 1824e3aafcb74aac26eda786d5a7af7589994b6a2e2ecf3a2bd286dd6740ca6e

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