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

Uploaded Python 3

File details

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

File metadata

  • Download URL: x402mail-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 f7fc50bd016d27e9b00611807795f06047d3843964aef98cc04ef7faa8f5048e
MD5 93f9faa51b24729efa538b09aee2b948
BLAKE2b-256 33d2ccaaaab4d5678f4a1689ad7f27aa2fbca1a9d3f74ff8b97bcd735086d46b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: x402mail-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a8b300ef244db0f485a8f285bf83cb2fdacc8a23998aecdf6b3314f2c43632d
MD5 5dd1a0f214ad421f5f24bde54b86eaca
BLAKE2b-256 3da6c7cf9f17b0988563d043f802f93df5743f23a1abd455e06333e4367e9710

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