skillfed

mailgun

Python SDK for Mailgun

mailgun v1.9.0 367.4K downloads/30d#7,197 on PyPI9
Permissive license Apache-2.0 Active released

What it is and what it does

Mailgun is the official Python SDK for Mailgun's email delivery platform. It wraps Mailgun's REST API to let you send transactional emails, manage sender domains, configure webhooks, retrieve delivery events, and access suppression lists—all from Python code. The SDK supports both synchronous (requests-based) and asynchronous (httpx/httpx2-based) clients, so you can integrate it into blocking or async applications.

The package handles common email workflows: sending plain or templated messages with attachments, scheduling delivery, tracking bounces and complaints, managing mailing lists, and querying delivery metrics and logs. It includes features like memory-safe attachment streaming, fluent message builders, strict payload validation, and development-mode credential redaction. The SDK is actively maintained, compatible with Python 3.11+, and carries an Apache-2.0 license.

Use it for:

  • Send transactional emails (password resets, order confirmations) from a web application using the synchronous client.
  • Build an async email notification system that queries delivery events and bounce data via streaming pagination.
  • Manage email domain configuration, DKIM keys, and tracking settings programmatically.
  • Implement a mailing list with suppression rules (bounces, unsubscribes, complaints) integrated into your application.
  • Monitor email delivery metrics and logs to track campaign performance and diagnose delivery issues.
  • Schedule emails for future delivery and attach files without loading entire payloads into memory.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Official Python SDK for the Mailgun email service API, providing synchronous and asynchronous clients to send messages, manage domains, webhooks, templates, and access email delivery metrics.

Yes. This is the official Mailgun SDK with active maintenance, low install friction, no known vulnerabilities, and broad API coverage. Install it if you use Mailgun for email delivery and want a well-supported, type-hinted Python client. The Alpha status reflects ongoing development, not instability—recent releases and active commits show it is production-ready.

Install

mailgun on PyPI

pip

pip install mailgun

uv

uv add mailgun

poetry

poetry add mailgun

Installing mailgun

Before you install

Active maintenance with a recent release (10 days old). Low install friction—pure Python wheel with three HTTP client options (requests, httpx, httpx2). Requires Python 3.11+.

License in practice

Apache-2.0 permissive license allows commercial and private use with minimal restrictions.

Quickstart

pip install mailgun

from mailgun import Mailgun

client = Mailgun(domain='example.com', api_key='your-api-key')
response = client.messages.send(to='user@example.com', subject='Hello', text='Test message')

Requires Python 3.11 or later. Mailgun API credentials (domain and API key) must be provided.

Verify before relying

  • Whether async support via httpx2 is production-ready or still experimental given the Alpha development status.
  • Performance characteristics when handling large attachment streams with ChunkedStreamer.
  • Exact retry and timeout defaults for exactly-once delivery semantics.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 3 — httpx2, httpx, requests
Maintenance actively maintained — 10 days since the last release
Last repo commit
First released
Downloads 367,377/month — #7,197 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mailgun-1.9.0-py3-none-any.whl

Keywords: email python-wrapper, mailgun, Mailgun API Python Wrapper, mailgun-api, Python SDK for Mailgun, transactional-emails, wrapper

Development Status :: 3 - AlphaEnvironment :: ConsoleIntended Audience :: DevelopersNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Communications :: EmailTopic :: Utilities

Tags

mailgun email api pythonsend emails with mailgun sdkmailgun python wrapperemail delivery tracking pythonmailgun async clienttransactional email pythonmailgun domain management
email-deliveryasync-supportapi-client

More Utilities packages