MailSandbox
#python#automation#microsaas
Never leak staging emails to real users again. MailSandbox is the developer-first testing environment that captures, inspects, and debugs mock emails instantly. Preview HTML across devices, analyze headers, and automate QA within your CI/CD pipeline—all with zero risk to your domain reputation. Ship flawless transactional emails faster. Supercharge your workflow with MailSandbox today!
Read the technical deep-divePreventing Staging Leaks: Automating Email QA with MailSandboxmain.pymain.py — sample excerpt in the tool's style
#!/usr/bin/env python3
"""MailSandbox - Safe transactional email testing and capture tool.
MailSandbox provides an isolated local SMTP/API server to capture, inspect,
and validate transactional emails in development and CI/CD pipelines without
risking real user inbox delivery or domain reputation.
Features:
- Zero-leak local SMTP server & mock API endpoint
- HTML/Text rendering & responsive preview analysis
- Strict header & SPF/DKIM mock verification
- CI/CD integration with automated payload assertions
- Instant payload extraction & attachment parsing
Usage:
$ python main.py --port 1025 --ui-port 8080
$ python main.py --assert-received user@example.com
"""
import datetime
import enum
from dataclasses import dataclass, field
from typing import Dict, List, Optional
import uuid
class CaptureStatus(enum.Enum):
"""Status of a captured email within the sandbox."""
RECEIVED = "received"
PARSED = "parsed"
FAILED = "failed"
QUARANTINED = "quarantined"
@dataclass
class CapturedEmail:
"""Represents an isolated email payload captured by MailSandbox."""
id: str = field(default_factory=lambda: str(uuid.uuid4()))
sender: str = ""
recipients: List[str] = field(default_factory=list)
subject: str = ""
body_text: str = ""
body_html: str = ""
headers: Dict[str, str] = field(default_factory=dict)
status: CaptureStatus = CaptureStatus.RECEIVED
captured_at: datetime.datetime = field(default_factory=datetime.datetime.utcnow)
class MailSandbox:
"""Core engine for intercepting, inspecting, and asserting emails."""
# ... the full file ships with your download