litestar-email

Send transactional email from Litestar apps through pluggable SMTP, Resend, SendGrid, or Mailgun backends.

Updated Aug 17, 2026
One-click install
npx skills add https://github.com/renjianguo666/litecms --skill litestar-email-renjianguo666
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: litestar-email
Source: https://github.com/renjianguo666/litecms/tree/main/.agents/skills/litestar-email
Command: npx skills add https://github.com/renjianguo666/litecms --skill litestar-email-renjianguo666

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Sending transactional email from a Litestar application usually means wiring backend-specific SDKs, managing credentials, and rewriting call sites whenever the provider changes. This Skill provides a single EmailConfig plus EmailPlugin abstraction so backends can be swapped without touching application code, and tests can run against an in-memory outbox instead of real network calls. ## Core Features & Use Cases - Pluggable backends: Choose SMTPConfig, ResendConfig, SendGridConfig, MailgunConfig, or InMemoryConfig and swap them via one config object. - Dependency injection: EmailPlugin registers EmailService automatically, so handlers simply declare an email_service parameter and call async send_message or send_messages. - Testable email flows: InMemoryConfig captures messages in an outbox list for assertions, and slow sends can be queued through litestar-saq background tasks. - Use Case: A user signs up, the controller enqueues a SAQ task, the task renders a Jinja2 template and sends a welcome email via Resend, and the test suite asserts the message landed in the in-memory outbox. ## Quick Start Set up litestar-email in my Litestar app with the Resend backend and inject EmailService into a handler that sends a welcome email.

Frequently Asked Questions about litestar-email

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I send email from a Litestar application?

Install litestar-email, create an EmailConfig with a backend such as SMTPConfig or ResendConfig, and register EmailPlugin on the Litestar app. Handlers then receive EmailService via dependency injection and call the async send_message method with an EmailMessage.

Which email backend should I use with litestar-email?

Use SMTPConfig for generic or corporate SMTP servers, ResendConfig for new projects needing a modern transactional API, and SendGridConfig or MailgunConfig when you already have those accounts. Use InMemoryConfig in all test environments.

How do I test Litestar email sending without real network calls?

Configure the plugin with InMemoryConfig in your test environment. Sent messages are captured in the email_service.outbox list, so tests can assert on recipient, subject, and body without contacting any external server.

Does litestar-email support HTML emails and attachments?

Yes. EmailMessage accepts html_body alongside a plain text body, plus cc, bcc, reply_to, custom headers, and file attachments. EmailMultiAlternatives supports attaching multiple alternative parts such as text/html via attach_alternative.

Should email sending block Litestar request handlers?

No. SMTP and HTTP backends can be slow, so blocking sends degrade request latency. The recommended pattern is to enqueue the send as a litestar-saq background task with timeout and retry settings, keeping handlers fast.

Does litestar-email include a templating engine?

No. It deliberately ships no templating engine. Render body and html_body strings beforehand using Litestar's Jinja2 integration, then pass the rendered strings into EmailMessage before sending.