Skip to main content

mailfixture

Email fixtures for your test suite. Create a programmatic inbox in one call, point your app's signup / OTP / password-reset flow at it, then wait for the email — parsed, with the OTP and links already extracted.

Receive-only, built for CI: long-polling instead of retry loops, zero dependencies outside the Python standard library, Python 3.9+.

pip install mailfixture

Quickstart

Create a key in Dashboard → API keys and export it as MAILFIXTURE_API_KEY.

from mailfixture import MailFixture

mfx = MailFixture()  # reads MAILFIXTURE_API_KEY

def test_signup_sends_otp(page):
    inbox = mfx.create_inbox(ttl_seconds=900)

    page.goto("/signup")
    page.fill("#email", inbox.email_address)
    page.click("text=Send code")

    otp = inbox.wait_for_otp(timeout=30)   # long-polls; no sleep()
    page.fill("#otp", otp)

Waiting for a magic link instead:

link = inbox.wait_for_link(kind="verify", timeout=30)
page.goto(link.url)

Everything on the wait helpers is server-side long-polling: the request is held open until a matching message arrives (or the timeout passes, raising mailfixture.MailFixtureTimeout).

API surface

Method Purpose
create_inbox(local_part=, domain=, ttl_seconds=) new inbox; returns an Inbox handle
inbox.wait_for_message(match=, timeout=) first matching message, full body + extraction
inbox.wait_for_otp(match=, timeout=) best extracted OTP as a string
inbox.wait_for_link(kind=, match=, timeout=) first link, optionally verify|reset|unsubscribe
inbox.messages(since=, match=, wait=) / clear() / delete() raw listing & lifecycle
get_message(id), get_otp(id), get_links(id) direct message access
download_attachment(message_id, index) decoded attachment bytes
create_domain(fqdn), verify_domain(id), list_domains(), delete_domain(id) custom domains
create_key(label=), list_keys(), revoke_key(id) API keys

match filters with subject:, from:, or to: prefixes; a bare term matches the subject.

Errors are raised as mailfixture.MailFixtureError carrying the API's RFC 7807 status / title / detail fields.

Development

PYTHONPATH=src python3 -m unittest discover -s tests

Docs: https://mailfixture.com/docs

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mailfixture-0.5.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

mailfixture-0.5.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file mailfixture-0.5.0.tar.gz.

File metadata

  • Download URL: mailfixture-0.5.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mailfixture-0.5.0.tar.gz
Algorithm Hash digest
SHA256 510e8ff59f178421022589b4c77b4fac4c6ddd7101b97ccc9eb58e350eb2de7b
MD5 19e6ef5e1a70bfaf2b760cb77e7c76a2
BLAKE2b-256 116fd575eb9d4acb921d3432b030c12e3ee349f93185f0ea7070ad9376564f70

See more details on using hashes here.

File details

Details for the file mailfixture-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: mailfixture-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mailfixture-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c6f500cbbe26952f900d7287e3a7e60fa3e9b7bec90a971a3dad87aaeb7016d
MD5 f70115fce4dafe69be33aa911f9f1f8d
BLAKE2b-256 b39fbb80da8661137feeb7fa890742845aca8ad30b2beeb932f619da953e2df9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.0

2 files

This release

0.5.0 This release

2 files

0.4.1

2 files

0.4.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page