Skip to content
DocumentationAPI referenceBuild something worth sending.

Guides

Send email from Supabase Edge Functions

Send email from a Supabase Edge Function with fetch. SendPanda has no SMTP server. Auth mail uses a Send Email hook.

Supabase Edge Functions run on Deno. SendPanda has no SMTP server, so a function sends with fetch to https://api.sendpanda.email/v1/emails. The same call works for any message, not only auth mail. Supabase auth emails, including the signed Send Email hook, are in the Supabase auth guide.

1. Send with fetch

Deno.serve(async (req) => {
  const user = await userFromRequest(req); // your own check
  if (!user) return new Response("Unauthorized", { status: 401 });
  const apiKey = Deno.env.get("SENDPANDA_API_KEY");
  const res = await fetch("https://api.sendpanda.email/v1/emails", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
      "Idempotency-Key": `welcome-${user.id}`,
    },
    body: JSON.stringify({
      from: "Your app <hello@your-verified-domain.com>",
      to: [user.email],
      subject: "Welcome",
      text: "Welcome",
    }),
  });
  if (!res.ok) return new Response("Email was not accepted", { status: 502 });
  const email = await res.json();
  return Response.json({ id: email.id, status: email.status });
});

A successful native response is HTTP 202 and { id, status }. Store the key with supabase secrets set SENDPANDA_API_KEY=sp_live_your_key. The from address must be on a verified SendPanda domain.

The SDK runs on Node.js 22 or newer, so this Deno function uses fetch against the REST API instead of the package.

A route that sends to any address a request supplies is an open relay. Decide the recipient from your own session or database. Use one idempotency key per business event, and reuse that same key if the request is retried.

↑↓ to navigate↵ to openesc to close