yagmail
Yet Another GMAIL client
What it is and what it does
Yagmail is a Python SMTP client designed to make sending emails as straightforward as possible. It wraps the standard library's SMTP functionality and adds convenience features like automatic content-type detection (plain text, HTML, images, attachments), support for multiple recipients with aliases, and both synchronous and asynchronous sending via asyncio. The package handles the common friction points of email composition—figuring out MIME types, encoding attachments, building multipart messages—so you can focus on the message content.
It works with Gmail (using Application-Specific Passwords or OAuth2) and any SMTP server. The API is minimal: instantiate a Client with credentials, then call send() with recipients, subject, and contents. Contents can be a mix of strings, file paths, and HTML snippets, and the library intelligently detects what each item is. An asynchronous version is built in for non-blocking email operations.
Use it for:
- Sending transactional emails (notifications, confirmations) from a Python application without managing SMTP boilerplate.
- Automating bulk email campaigns with attachments and HTML formatting from a script or scheduled task.
- Building a command-line email tool that accepts recipients, subject, and file attachments as arguments.
- Integrating email alerts into monitoring or logging systems with minimal code overhead.
- Sending emails asynchronously in a web application to avoid blocking request handlers.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Simplifies sending emails via Gmail or any SMTP server, with built-in support for attachments, HTML content, and asynchronous sending.
Yes. Yagmail is actively maintained, has no known vulnerabilities, low install friction, and a permissive MIT license. It is well-suited for developers who need straightforward email sending without the complexity of raw SMTP or heavier frameworks. Use it when you want to send emails quickly from Python without boilerplate—particularly for Gmail or simple SMTP scenarios. The built-in async support and intelligent content handling make it practical for both scripts and applications.
Install
yagmail on PyPI
pip
pip install yagmailuv
uv add yagmailpoetry
poetry add yagmailInstalling yagmail
Before you install
Low install friction with a single runtime dependency (premailer). Active maintenance with a recent release (80 days ago) and 2731 repository stars indicate ongoing support and community use.
License in practice
MIT license is permissive, allowing free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install yagmail
import yagmail
yag = yagmail.Client('mygmailusername', 'mygmailpassword')
yag.send('to@someone.com', 'subject', 'body text')
Gmail requires an Application-Specific Password (regular account passwords no longer work over SMTP); alternatively, OAuth2 authentication can be used.
Verify before relying
- Whether premailer dependency is required for all use cases or only for HTML email rendering.
- Current state of OAuth2 token refresh behavior and whether the 7-day expiry limitation still applies.
- Performance characteristics when sending bulk emails or handling large attachments.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — premailer |
| Maintenance | actively maintained — 80 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 382,123/month — #7,092 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: yagmail-0.16.0-py3-none-any.whl
Keywords: email, mime, automatic, html, attachment
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI 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
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
emailsBuild and send HTML and plain-text emails with…
permissive · top 15,000 on PyPI
fastapi-mailSends emails and attachments asynchronously…
permissive · top 5,000 on PyPI
simplegmailA Python wrapper around the Gmail API that…
permissive · top 15,000 on PyPI
django-post_officeDjango Post Office queues and sends emails…
permissive · top 15,000 on PyPI
redmailRedmail simplifies sending emails with Python…
permissive · top 15,000 on PyPI
azure-communication-emailSends emails via Azure Communication Services,…
permissive · top 5,000 on PyPI
aiosmtplibaiosmtplib is an asynchronous SMTP client that…
permissive · top 5,000 on PyPI
sparkpostOfficial Python client for the SparkPost email…
permissive · top 15,000 on PyPI
resendResend Python SDK provides a client library for…
permissive · top 5,000 on PyPI
aiosmtpdaiosmtpd is an asyncio-based SMTP server that…
permissive · top 5,000 on PyPI