A Python library for sending emails conveniently via Gmail/SMTP with minimal code.
yagmail is a Python library that provides a simple and intuitive interface for sending emails via Gmail and SMTP servers. It solves the problem of verbose and complex email-sending code by abstracting away low-level details like MIME types and SMTP connections, allowing developers to send emails, attachments, and HTML content with minimal effort.
Python developers who need to send emails programmatically, such as those building automation scripts, notification systems, or applications that require email functionality without dealing with `smtplib` complexities.
Developers choose yagmail for its extreme simplicity and clean API, which reduces email-sending code to just a few lines. It offers smart content handling, OAuth2 security, and DKIM support out of the box, making it a hassle-free alternative to manual SMTP implementations.
Send email in Python conveniently for gmail using yagmail
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Reduces email sending to just a few lines of code, as shown with `yag.send()` that handles recipients, subject, and contents effortlessly, abstracting away `smtplib` complexities.
Automatically attaches local files, embeds images, and formats HTML or text based on content type, allowing mixed content in a list without manual MIME handling.
Supports secure Gmail authentication via OAuth2 tokens, enabling token revocation and avoiding password storage, with setup prompts for credentials as described in the README.
Integrates DKIM signatures for improved email deliverability and security, available via an optional installation (`yagmail[dkim]`) with straightforward configuration.
While it supports SMTP, the library is optimized for Gmail, and features like OAuth2 setup are tailored to Google's ecosystem, potentially complicating use with other providers.
The core library is synchronous; for asynchronous operations, developers must use the separate aioyagmail project, adding complexity and fragmentation for async projects.
When attaching files via `io.IOBase` streams without a `.name` attribute, yagmail defaults to generic names like 'attachment1' without extensions, as noted in the README, which can lead to usability problems.