Skip to main content

Lightweight Python SDK for MailAPI (https://mailapi.freetools.fr)

Project description

MailAPI Python SDK

A lightweight, typed Python client for the MailAPI-Freetools service (https://mailapi.freetools.fr) to generate disposable inboxes and fetch messages.


Features

  • Synchronous (MailAPI) and asynchronous (AsyncMailAPI) clients.
  • Endpoints: /ping, /get_email, /{email}.
  • High-level wait_for_message() utility for polling a mailbox.
  • Typed dataclasses for responses (GeneratedEmail, Message, Messages).
  • Detailed error classes: BadRequest, Unauthorized, Forbidden, ServerError, MailAPIError.

Installation

pip install mailapi_freetools

Quick Start (Synchronous)

from mailapi_freetools import MailAPI

client = MailAPI(api_key="YOUR_API_KEY")
info = client.get_email()
print(info.email)           # generated address
print(info.mails_endpoint)  # endpoint to poll messages

msgs = client.get_messages(info.email)
for m in msgs.messages:
    print(m.subject, m.received_at)

Quick Start (Asynchronous)

import asyncio
from mailapi_freetools import AsyncMailAPI

async def main():
    client = AsyncMailAPI(api_key="YOUR_API_KEY")
    info = await client.get_email()
    print(info.email)
    await client.aclose()

asyncio.run(main())

Waiting for a Specific Email

from mailapi_freetools import MailAPI

client = MailAPI(api_key="YOUR_API_KEY")
addr = client.get_email().email
msg = client.wait_for_message(addr, subject_contains="Your code", timeout=60)
if msg:
    print("Found:", msg.subject)
else:
    print("Timed out.")

Error Handling

from mailapi_freetools import MailAPI, MailAPIError

try:
    MailAPI(api_key="...").ping()
except MailAPIError as e:
    print(e.status_code, e)

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

mailapi_freetools-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

mailapi_freetools-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file mailapi_freetools-0.1.0.tar.gz.

File metadata

  • Download URL: mailapi_freetools-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mailapi_freetools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f33cf00e285b425134967dfadcc1250b227540c47c26563d03dfe3006887098
MD5 4a3e8cadc6c01ef04a3baf811cbd40e8
BLAKE2b-256 3645f3571a22ea2d9903129741d66b145536ceff44dc94de1c65fac765adf606

See more details on using hashes here.

File details

Details for the file mailapi_freetools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mailapi_freetools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a86bcd8258f47cb2ce66312ead62d2a830fb74ebb521aa98c80a888aad9ccedf
MD5 ef84274ace29191d58854a1ba74eff17
BLAKE2b-256 e99512d1206a96508f623d7f6c65be51f4337772ccf872b9a317b9e5955e04e2

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