Developer guides
Updated
Send email from your code
Working code for the frameworks you already use. Every guide covers setup, environment variables, error handling, idempotent retries, domain verification and a production checklist.
Frameworks and languages
- Next.jsSend emails from Next.jsApp Router route handlers and server actions with the lumail SDK.
- Node.jsSend emails from Node.jsA script, an Express route, batch sends and a safe retry helper.
- PythonSend emails from PythonCall the REST API with requests or httpx, from scripts, Flask or FastAPI.
- TanStack StartSend emails from TanStack StartServer functions and server routes that keep the key on the server.
Templates and events
Building with an AI tool instead?
Frequently asked questions
What do I need before following a Lumail developer guide?
A Lumail account, an API token that starts with lum_, and a sending domain verified in the same organization. The Free plan includes 3,000 emails a month, so you can follow every guide without paying.
Is there an official Lumail SDK?
Yes, the lumail package on npm. It is typed, works in Node.js 20 and later, and returns { data, error } instead of throwing. Other languages call the REST API at https://lumail.io/api/v2 with a bearer token.
Can I send transactional and marketing email from the same account?
Yes. API sends, campaigns and automations share one organization and one verified domain. Transactional sends use a priority lane, so a newsletter going out does not delay a password reset.
How do I avoid sending the same email twice?
Pass an idempotency key with every send that can be retried, built from the event that caused it, such as a user id or a Stripe event id. Repeating the key returns the email already queued.
How do I test without emailing real people?
Send to fixture addresses such as [email protected] or any .test domain. Lumail runs the full send path and returns an id, but never delivers the message.
Ship email from your code this afternoon.
3,000 emails a month free. Unlimited subscribers on every plan. Campaigns, automations and transactional email on one domain.