mailtrap
Official mailtrap.io API client
What it is and what it does
Mailtrap is the official Python client for Mailtrap's email platform, a service that combines email sending (transactional and bulk streams) with sandbox testing and contact management. It wraps Mailtrap's REST API behind a Pythonic interface, letting you send individual or batch emails, use pre-built templates, manage inboxes and messages in a sandbox environment, and handle contacts and mailing lists. The package depends only on requests for HTTP calls and pydantic for data validation, keeping the installation lightweight.
You use it by instantiating a MailtrapClient with your API token, then constructing Mail or MailFromTemplate objects and calling send() or batch_send(). The client supports switching between sandbox (for testing) and production (for live sending) via configuration flags. It's designed for developers integrating email into Python applications who want a managed service rather than self-hosted SMTP infrastructure.
Use it for:
- Send transactional emails (password resets, order confirmations) from a Python web application.
- Test email templates and rendering in a sandbox before deploying to production.
- Manage bulk email campaigns with template variables and contact lists.
- Validate email content and HTML/CSS compliance using Mailtrap's testing sandbox.
- Integrate email sending into a Django, FastAPI, or Flask application without configuring SMTP.
- Batch-send personalized emails to multiple recipients with template substitution.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Official Python client for Mailtrap's email sending and testing APIs, supporting transactional and bulk email delivery, sandbox testing, templates, and contact management.
Yes. The package is actively maintained, has minimal dependencies, supports current Python versions, carries no known vulnerabilities, and is MIT-licensed. Install it if you are already using Mailtrap or evaluating it as your email service. Skip it if you need a generic SMTP client or are committed to a different email provider.
Install
mailtrap on PyPI
pip
pip install mailtrapuv
uv add mailtrappoetry
poetry add mailtrapInstalling mailtrap
Before you install
Low install friction with only two runtime dependencies (requests and pydantic). Actively maintained with recent releases; last commit 2026-08-14 and version released 2026-08-04. Supports current Python versions (3.9+).
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for commercial and open-source projects alike.
Quickstart
pip install mailtrap
import mailtrap as mt
import os
client = mt.MailtrapClient(token=os.environ["MAILTRAP_API_KEY"])
mail = mt.Mail(
sender=mt.Address(email="sender@example.com", name="John Smith"),
to=[mt.Address(email="recipient@example.com")],
subject="Test",
text="Hello!",
)
client.send(mail)
Requires Python 3.9 or later and a valid Mailtrap API token from https://mailtrap.io/api-tokens.
Verify before relying
- Rate limits or quota constraints for transactional vs. bulk sending streams.
- Whether the package supports async/await patterns for concurrent email sending.
- Specific retry behavior and timeout defaults for API calls.
Package facts
| License | The MIT License (MIT) Copyright (c) 2023 Railsware Products Studio LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — requests, pydantic |
| Maintenance | actively maintained — 10 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 110,187/month — #12,480 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mailtrap-2.7.0-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
django-anymailSends and receives email in Django through…
permissive · top 5,000 on PyPI
mailslurp-clientMailSlurp provides a Python client for an email…
unclear · top 15,000 on PyPI
neverbounce-sdkPython client library for the NeverBounce email…
permissive · top 15,000 on PyPI
postmarkerPostmarker is a Python client library for the…
permissive · top 5,000 on PyPI
sendsafelyIntegrates SendSafely secure file transfer and…
permissive · top 15,000 on PyPI
mailgunOfficial Python SDK for the Mailgun email…
permissive · top 15,000 on PyPI
resendResend Python SDK provides a client library for…
permissive · top 5,000 on PyPI
mailchimp-transactionalA Python client library for the Mailchimp…
unclear · top 15,000 on PyPI
smsapi-clientA Python client library for sending SMS…
permissive · top 15,000 on PyPI
redmailRedmail simplifies sending emails with Python…
permissive · top 15,000 on PyPI