Email

Libraries for sending email.

Sending from Django, you learn no new Python email library API: django-anymail runs send_mail(). Async code sends mail through aiosmtplib.

How to choose:

  • A Django app sending through Amazon SES, Mailgun, Postmark, or another email service: django-anymail
  • A Django app that tracks delivery or receives email through that service: django-anymail
  • Async code talking to an SMTP server: aiosmtplib
  • A script sending from Gmail, or any SMTP account, with attachments: yagmail

Listed in editorial order. Click a column header to re-sort the whole list.

Press / to search. Tags open their category. Click a row for details.

Search and filter

Results

Row number Tags
An asyncio SMTP client.
cole/github.com/cole/aiosmtplib /436 stars /
Django email backends and webhooks for transactional email services such as Amazon SES, Brevo, Mailgun, Postmark, and Resend.
anymail/github.com/anymail/django-anymail /1,915 stars /
Yet another Gmail/SMTP client.
kootenpv/github.com/kootenpv/yagmail /2,739 stars /

Email guide

django-anymail extends Django's django.core.mail with features email services add, through one API that doesn't lock your code to one service. Change Django's email backend to Anymail's backend for your service, and send_mail(), EmailMessage, and even mail_admins() send through it unchanged. Send from a background task, not the view: Anymail calls that a best practice for sending email from Django, since your views respond faster. To track delivery or receive email, connect the service's webhooks to Anymail's Django signals, and protect them with https and a shared secret.

aiosmtplib is an async version of smtplib, with similar APIs. Build each message as the standard library's EmailMessage, which makes headers easier to work with. Then pass it to the send() coroutine, which the docs recommend for most use cases.

yagmail aims to make sending email as simple as possible, with Gmail as its default server. Its contents argument is guessed item by item: a path to a local file becomes an attachment, valid HTML becomes HTML, and anything else is text. For Gmail, sign in with an app password or OAuth2.

Know a project that belongs here?

Tell us what it does and why it stands out.