Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mailpit-testing

БесплатноБез исполняемых скриптовНе проверен

Use for any question or task about testing email your code sends, including one password-reset or signup email and broken links in sent mail: capture messages…

testlandот testland★ 18 звёзд на GitHub

Об этом скилле

mailpit-testing

Overview

Mailpit is an SMTP server for tests: it captures every message the app sends, shows it in a web UI and exposes it through a REST API, and its Chaos feature returns configurable SMTP errors for resilience tests ([docs][mp-docs]). It never delivers mail.

When to use

  • The app sends transactional email (password reset, sign-in links, notifications) and tests must assert on what was sent.
  • Retry and dead-letter code needs real SMTP errors (Chaos, Step 5).
  • The full flow needs coverage beyond capture (headers, multipart, links, unsubscribe, bounces): references/email-flows.md.
  • An existing MailHog setup is being replaced: references/migrating-to-mailpit.md.

Step 1 - Run it

docker run -d --name mailpit -p 8025:8025 -p 1025:1025 axllent/mailpit:v1.32
# or: brew install mailpit && mailpit

SMTP listens on 1025 and the web UI / API on 8025 ([repository][mp-gh]). Pin an image tag; the API changes between releases. Prefer the image or a release binary over the repository's install script, which pipes remote code into a root shell.

Check it is up before any test:

curl -fsS http://localhost:8025/api/v1/info   # 200 with version and message count

Step 2 - Point the app at it

Stack Setting
Django EMAIL_HOST=localhost, EMAIL_PORT=1025
Spring spring.mail.host=localhost, spring.mail.port=1025
Rails smtp_settings: { address: "localhost", port: 1025 }
Nodemailer createTransport({ host: "localhost", port: 1025 })

Mailpit accepts unauthenticated SMTP by default ([SMTP options][mp-smtp]). If production uses SMTP auth, test it for real: start Mailpit with --smtp-auth-file <file> --smtp-auth-allow-insecure and add a test that a wrong password is rejected. Never use --smtp-auth-accept-any for that: it accepts any username and password, or none, so a broken credential still passes ([SMTP options][mp-smtp]).

Step 3 - Give each test its own address

Tests that share one mailbox and clear it with DELETE /api/v1/messages delete each other's mail when they run in parallel. Instead, send each test to a unique plus-address. Plus-addressing tags are on by default: [email protected] gets the tag t-3f9a ([tagging][mp-tag]).

# tests/email/mailpit.py
import time, uuid, requests

BASE = "http://localhost:8025"

def unique_address(local="alice", domain="example.com"):
    return f"{local}+t-{uuid.uuid4().hex[:8]}@{domain}"

def wait_for_message(to, timeout=5.0):
    """Poll search scoped to one recipient; return the full message."""
    deadline = time.monotonic() + timeout
    while time.monotonic() < deadline:
        found = requests.get(f"{BASE}/api/v1/search",
                             params={"query": f'to:"{to}"'}, timeout=2).json()
        if found["messages"]:
            msg_id = found["messages"][0]["ID"]
            return requests.get(f"{BASE}/api/v1/message/{msg_id}", timeout=2).json()
        time.sleep(0.1)
    raise AssertionError(f"no message to {to} within {timeout}s")

def delete_messages_to(to):
    requests.delete(f"{BASE}/api/v1/search", params={"query": f'to:"{to}"'}, timeout=2)

GET /api/v1/search and DELETE /api/v1/search take the same search query, so a test only ever reads or deletes its own messages ([API][mp-api]). Clean up in teardown with delete_messages_to, or not at all; never with an unscoped delete on a parallel path.

Step 4 - Assert on the full message

import re

def test_password_reset_email():
    to = unique_address()
    trigger_password_reset(to)              # the app call under test
    msg = wait_for_message(to)

    assert msg["Subject"] == "Reset your password"
    assert msg["To"][0]["Address"] == to
    assert msg["From"]["Address"] == "[email protected]"
    m = re.search(r"/reset\?token=([A-Za-z0-9_-]{20,})", msg["Text"])
    assert m, "reset link with a real token missing from the text part"
    assert m.group(1) != "undefined"

GET /api/v1/message/{ID} (singular) returns Subject, From, To, Text and HTML ([API][mp-api]). Assert on extracted values directly: an assertion inside a loop over links passes when the list is empty. Message IDs are generated per send, so never hard-code one.

Step 5 - Chaos: real SMTP errors

Start Mailpit with Chaos enabled (--enable-chaos, or --chaos-triggers Sender:451:100 to set a trigger at startup) ([Chaos][mp-chaos]). Then set triggers per test through the API:

def set_chaos(**triggers):
    # e.g. set_chaos(Recipient={"ErrorCode": 451, "Probability": 100})
    r = requests.put(f"{BASE}/api/v1/chaos", json=triggers, timeout=2)
    r.raise_for_status()

def test_transient_error_is_retried():
    to = unique_address()
    set_chaos(Recipient={"ErrorCode": 451, "Probability": 100})
    try:
        send_notification(to)                # app should queue a retry
Полный SKILL.md на GitHub

Установить mailpit-testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonevals/auditor-checklist-half-of-which-we-cannot-verify-here/criteria.jsonevals/auditor-checklist-half-of-which-we-cannot-verify-here/task.mdevals/four-workers-wiping-each-others-inbox/criteria.jsonevals/four-workers-wiping-each-others-inbox/task.mdevals/green-suite-while-reset-links-shipped-broken/criteria.jsonevals/green-suite-while-reset-links-shipped-broken/task.mdevals/retry-queue-written-after-the-relay-outage/criteria.jsonevals/retry-queue-written-after-the-relay-outage/task.mdevals/smtp-auth-typo-that-only-staging-caught/criteria.jsonevals/smtp-auth-typo-that-only-staging-caught/task.mdreferences/email-flows.mdreferences/mailhog-legacy.mdreferences/migrating-to-mailpit.md

FAQ

Что делает скилл mailpit-testing?

Use for any question or task about testing email your code sends, including one password-reset or signup email and broken links in sent mail: capture messages in Mailpit's local SMTP server (port 1025), assert on subject, body and links through its REST API, test SMTP failures with chaos mode, multipart, unsubscribe and bounce flows, or migrate from MailHog.

Как установить скилл mailpit-testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mailpit-testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mailpit-testing с