Skip to main content

Official Python SDK for FreeCustom.Email — disposable inboxes, OTP extraction, real-time WebSocket delivery

Project description

freecustom-email Python SDK

PyPI License

Official Python SDK for FreeCustom.Email — the ultimate API for disposable inboxes, automated OTP extraction, and real-time email delivery via WebSockets.

🚀 Features

  • Disposable Inboxes: Instantly register and manage temporary email addresses.
  • Automated OTP Extraction: Automatically extract verification codes from incoming emails.
  • Real-time Delivery: Receive emails instantly via high-performance WebSockets.
  • Async & Sync Support: Native asyncio support with an optional synchronous interface.
  • Custom Domains: Manage and verify your own custom domains for personalized temporary mail.
  • Webhooks: Programmatically manage HTTP webhooks for email notifications.
  • Type-Safe: Full typing support for a better developer experience.

📦 Installation

pip install freecustom-email

🛠 Quick Start

1. Initialize the Client

Get your API key from the FreeCustom.Email Dashboard.

from freecustom_email import FreeCustomEmail

client = FreeCustomEmail(api_key="fce_your_api_key")

2. Async Usage (Recommended)

import asyncio
from freecustom_email import FreeCustomEmail

async def main():
    client = FreeCustomEmail(api_key="fce_...")

    # Register an inbox (pass is_testing=True for zero-latency testing, Growth plan+)
    await client.inboxes.register("test@ditube.info", is_testing=True)
    print("Inbox registered!")

    # Wait for an OTP (Growth plan+)
    print("Waiting for OTP...")
    otp = await client.otp.wait_for("test@ditube.info", timeout_ms=60_000)
    print(f"Your OTP is: {otp}")

    # List recent messages
    messages = await client.messages.list("test@ditube.info")
    for msg in messages:
        print(f"Subject: {msg.subject} | From: {msg.from_}")

if __name__ == "__main__":
    asyncio.run(main())

3. Sync Usage

from freecustom_email import FreeCustomEmail

client = FreeCustomEmail(api_key="fce_...", sync=True)

# Register and wait (pass is_testing=True for zero-latency testing)
client.inboxes.register("sync-test@ditube.info", is_testing=True)
otp = client.otp.wait_for("sync-test@ditube.info")
print(f"OTP received: {otp}")

⚡️ Real-time WebSockets

Connect to our WebSocket server to receive emails instantly as they arrive.

import asyncio
from freecustom_email import FreeCustomEmail

async def main():
    client = FreeCustomEmail(api_key="fce_...")
    
    # Subscribe to a specific mailbox or all emails on your plan
    ws = client.realtime(mailbox="test@ditube.info")

    @ws.on("connected")
    async def on_connect(info):
        print(f"Connected! Subscribed inboxes: {info.subscribed_inboxes}")

    @ws.on("email")
    async def on_email(email):
        print(f"New Email! Subject: {email.subject}")
        if email.otp:
            print(f"Extracted OTP: {email.otp}")

    @ws.on("error")
    async def on_error(event):
        print(f"WS Error: {event.message}")

    await ws.connect()
    await ws.wait() # Block and keep listening

asyncio.run(main())

🧩 Advanced Features

Automated Verification Flow

The get_otp_for_inbox helper handles the entire lifecycle: register → trigger → wait → unregister.

async def trigger_signup():
    # Your code to click "Send OTP" on a website
    pass

otp = await client.get_otp_for_inbox(
    inbox="verify@ditube.info",
    trigger_fn=trigger_signup,
    timeout_ms=30_000
)

Custom Domains

Manage your own domains directly through the SDK.

# Add a new custom domain
result = await client.domains.add("my-temp-mail.com")

# Check verification status
status = await client.domains.verify("my-temp-mail.com")
if status.verified:
    print("Domain is ready to use!")

🛡 Error Handling

The SDK provides typed exceptions for precise error management.

from freecustom.errors import AuthError, PlanError, RateLimitError, WaitTimeoutError

try:
    await client.inboxes.register("test@invalid")
except AuthError:
    print("Invalid API key.")
except PlanError as e:
    print(f"Plan limit reached. Upgrade at: {e.upgrade_url}")
except WaitTimeoutError:
    print("No email arrived within the timeout period.")

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🔗 Links

Observability & Debugging

# Fetch the event timeline for an inbox
timeline = client.inboxes.get_timeline('test@domain.com')
print(timeline)

# Start a test boundary (creates a test run ID and logs a 'test_started' event)
test_result = client.inboxes.start_test('test@domain.com', 'my-test-run-123')
print('Test started:', test_result.test_id)

# Fetch timeline filtered by test run
filtered_timeline = client.inboxes.get_timeline('test@domain.com', 'my-test-run-123')
print(filtered_timeline)

# Fetch failure insights and warnings
insights = client.inboxes.get_insights('test@domain.com')
print(insights)

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

freecustom_email-1.0.4.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

freecustom_email-1.0.4-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file freecustom_email-1.0.4.tar.gz.

File metadata

  • Download URL: freecustom_email-1.0.4.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for freecustom_email-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f535fe11ba63c43298b7c944981efd18d0d483d6bd0dc28bc048170bfef51c06
MD5 8a58a4f7c9cff7c9ca76593a5cbb2b14
BLAKE2b-256 920f236a51ebfd8a7f458e64319efd0c955d7dc2ad719f23e26cb24630f6ddd2

See more details on using hashes here.

File details

Details for the file freecustom_email-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for freecustom_email-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e6c5822a977da6136cd460b27e0afc57b824fe2c4437328a981e775ede427fcf
MD5 eaef3b0d46217b1d94aa9ff6c3007f27
BLAKE2b-256 76e1da3f015a8f1c9ebf32cc1016b1d1e034aa6da2b74c7d2235c43b2fe070e4

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