Skip to main content

MailCheckr for Python

Server-side Python client for the MailCheckr API. Requires Python 3.9 or newer and has no runtime dependencies.

Install

pip install mailcheckr

Set MAILCHECKR_API_KEY in your server environment. Keep it out of browser code and source control.

Verify an email

from mailcheckr import MailCheckrClient

client = MailCheckrClient()
result = client.verify("person@example.com", "verify-user-123")

if result.is_pending:
    # Save result.id and poll later, or handle a webhook.
    result = client.find(result.id)

if result.is_deliverable:
    # A completed verification marked this address deliverable.
    pass

Use a stable idempotency key for each verification. Reuse it for retries of the same email; using it for another email receives HTTP 409. HTTP 200 and 202 both return VerificationResult. Pending states are queued, processing, and retry_scheduled. Completed statuses include deliverable, undeliverable, risky, and unknown. Only a completed deliverable result passes is_deliverable.

VerificationResult also exposes id, state, status, is_completed, is_failed, is_undeliverable, is_risky, is_unknown, and to_dict(). find() retrieves a result by ID. Do not poll in a tight loop.

The client accepts api_key, base_url (default https://mailcheckr.app/api/v1), and timeout in seconds (default 30). Non-success HTTP responses raise MailCheckrError with status and response fields. Network and timeout errors are raised by Python's urllib.

Verify webhooks

Verify the exact raw request body before parsing JSON:

import json
from mailcheckr import WebhookVerifier

verifier = WebhookVerifier()  # Reads MAILCHECKR_WEBHOOK_SECRET

def handle_webhook(raw_body: bytes, headers: dict[str, str]) -> None:
    if not verifier.verify(raw_body, headers):
        raise ValueError("Invalid MailCheckr webhook signature")
    event = json.loads(raw_body)
    # Persist and deduplicate event["id"] before applying effects.

verify_payload(raw_body, timestamp, signature) is also available. The default timestamp tolerance is 300 seconds and can be changed with WebhookVerifier(tolerance=...). Valid deliveries may be retried, so deduplicate event IDs in persistent storage.

Development

python -m pip install -e .
python -m unittest discover -s tests -v
python -m pip wheel . --no-deps -w dist

License

MIT. See LICENSE.

Contributing

Contributions are welcome. See CONTRIBUTING.md for setup and pull request guidance.

Report security issues privately as described in SECURITY.md.

Metadata

Release files for mailcheckr 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mailcheckr 0.1.0
File Size Uploaded
mailcheckr-0.1.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mailcheckr 0.1.0
File Interpreter ABI Platform
mailcheckr-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / mailcheckr-0.1.0.tar.gz

Download URL mailcheckr-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
901691a678b56d0ecd1d9f2d31ef09a12bd11dcc9042b7e9b22b494ee008e053
BLAKE2b-256 checksum
How to use checksums
c08e29139d5b33adb7291539d34e5c44e277cc2235a1d0a45eb95cd08feea5b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.1

Release files / mailcheckr-0.1.0-py3-none-any.whl

Download URL mailcheckr-0.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eff51513005a8f973d9be14af3ebbb81ed5dfc462c86767d3cd078eb16c40a5b
BLAKE2b-256 checksum
How to use checksums
84bcdb3d07f5c89c9d0c9c72fdde4b87248231d87052bca0af7a55de0c377012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page