Skip to content
DocumentationAPI referenceBuild something worth sending.

Guides

Send email with Remix

Send email from a Remix action with the SendPanda SDK. Keep the API key on the server and choose the recipient yourself.

Send from a Remix action on Node.js 22 or newer. Keep the key in the server environment. For Edge, Deno or Workers, call the REST API directly.

1. Install

npm install @sendpanda/sdk

Create a Send emails key and store it as SENDPANDA_API_KEY. The from address has to be on a domain verified in that project. See domain setup. A queued status means the API accepted the email, not that the recipient's server delivered it.

2. Send from an action

import type { ActionFunctionArgs } from "@remix-run/node";
import { SendPanda } from "@sendpanda/sdk";

const panda = new SendPanda(process.env.SENDPANDA_API_KEY!);

export async function action({ request }: ActionFunctionArgs) {
  const form = await request.formData();
  const userId = String(form.get("userId") ?? "");
  const to = "person@example.com"; // look this up; do not trust the form
  const email = await panda.emails.send(
    {
      from: "Your app <hello@your-verified-domain.com>",
      to: [to],
      subject: "Welcome",
      text: "Welcome",
    },
    { idempotencyKey: `welcome-${userId}` },
  );
  return Response.json({ id: email.id, status: email.status });
}

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