Skip to main content

MailOdds Email Validation API - SDK and CLI

Project description

MailOdds SDK for Python

Enterprise-ready Python client for the MailOdds Email Validation API.

Installation

pip install mailodds

Quick Start

import mailodds
from mailodds.api import EmailValidationApi
from mailodds.models import ValidateRequest

config = mailodds.Configuration(access_token="mo_live_your_api_key")

with mailodds.ApiClient(config) as client:
    api = EmailValidationApi(client)
    result = api.validate_email(ValidateRequest(email="user@example.com"))

    # Branch on action for decisioning
    match result.action:
        case "accept":
            print("Safe to send")
        case "accept_with_caution":
            print("Valid but risky -- flag for review")
        case "reject":
            print("Do not send")
        case "retry_later":
            print("Temporary failure -- retry after backoff")

Enterprise Features

This SDK includes enterprise-ready features beyond the generated API client:

Built-in Retry (429/5xx)

from mailodds.enterprise import RetryConfig, retry_api_client

config = mailodds.Configuration(access_token="mo_live_your_api_key")

with mailodds.ApiClient(config) as client:
    retry_api_client(client, RetryConfig(max_retries=3, base_delay=1.0))
    api = EmailValidationApi(client)
    # Automatically retries on 429/5xx with exponential backoff
    result = api.validate_email(ValidateRequest(email="user@example.com"))

Typed Errors

from mailodds.enterprise import MailOddsError, InsufficientCreditsError
from mailodds.exceptions import ApiException

try:
    result = api.validate_email(request)
except ApiException as e:
    error = MailOddsError.from_exception(e)
    if isinstance(error, InsufficientCreditsError):
        print(f"Need {error.credits_needed} credits, have {error.credits_available}")
        print(f"Upgrade: {error.upgrade_url}")

Webhook Signature Verification

from mailodds.enterprise import WebhookVerifier

verifier = WebhookVerifier("your_webhook_secret")

payload = request.get_data(as_text=True)
signature = request.headers.get("X-MailOdds-Signature", "")

event = verifier.verify_and_parse(payload, signature)
print(f"Event: {event['event']}")
print(f"Job ID: {event['job']['id']}")

Response Handling

Branch on the action field for decisioning:

Action Meaning Recommended
accept Safe to send Add to mailing list
accept_with_caution Valid but risky (catch-all, role account) Flag for review
reject Invalid or disposable Do not send
retry_later Temporary failure Retry after backoff

Test Mode

Use an mo_test_ prefixed API key with test domains for predictable responses without consuming credits.

API Reference

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

mailodds-0.2.0.tar.gz (61.2 kB view details)

Uploaded Source

Built Distribution

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

mailodds-0.2.0-py3-none-any.whl (140.8 kB view details)

Uploaded Python 3

File details

Details for the file mailodds-0.2.0.tar.gz.

File metadata

  • Download URL: mailodds-0.2.0.tar.gz
  • Upload date:
  • Size: 61.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for mailodds-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f685182689a144b041871ad32a3407e1f1d317a3b62b8ba38a5756586c066594
MD5 49b306ca17c4ecac092c603e2cef6b83
BLAKE2b-256 4a0db629a475d6e3cac42d015220b3757abfa50fcf67b155213f2f155c5c3fab

See more details on using hashes here.

File details

Details for the file mailodds-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mailodds-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 140.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for mailodds-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9acafe692e0d8ffd490b0e21c55744f5e261951931b41d38af96b376dc5e6cc
MD5 bb440a07fb84fe350e0b5c03a06cbb72
BLAKE2b-256 9dd63bcfd9d63eac57e85fdd017c86373db0fd8b437a9345ce0bb78ecdf48c31

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