Send email from Supabase with Lettr
Lettr works with Supabase through SMTP for Supabase Auth and the HTTP API from Edge Functions.
Checked
What you can do
- Send Supabase Auth confirmation, password reset, magic link and invite emails
- Send transactional email from Edge Functions
- Trigger email from Database Webhooks when a row changes
- See every message and its delivery status in the Lettr logs
How to set it up
- 1 In your Supabase project, open Authentication, then SMTP Settings, and turn on Enable Custom SMTP.
- 2 Set the sender email to an address on a domain you verified in Lettr.
- 3 Enter host smtp.lettr.com, port 465, username lettr, and your Lettr API key as the password.
- 4 Save. Supabase Auth emails now send through Lettr.
For email beyond Auth, store your key with supabase secrets set LETTR_API_KEY=… and call the API from an Edge Function.
Deno.serve(async (req) => {
const { to, subject, html } = await req.json();
const res = await fetch("https://app.lettr.com/api/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${Deno.env.get("LETTR_API_KEY")}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "noreply@yourdomain.com",
to: [to],
subject,
html,
}),
});
return new Response(await res.text(), { status: res.status });
});Requirements
- A Supabase project
- A sending domain verified in Lettr
- A Lettr API key
Links
Questions
- Can Supabase Auth send its emails through Lettr?
- Yes. Turn on custom SMTP in Supabase Auth and enter smtp.lettr.com, port 465, username lettr and your Lettr API key. Confirmation, password reset, magic link and invite emails then send through Lettr.
- Can I keep using Supabase's email templates?
- Yes. Supabase renders its auth templates, including variables such as {{ .ConfirmationURL }}, before it hands the message to Lettr for delivery.