# Send email from Next.js

> Send transactional email from a Next.js route handler or Server Action with Scribase Mail: the Resend-compatible API, the resend npm SDK, one base URL change.

Source: https://scribase.com/mail/send-email-nextjs

Scribase Mail serves the Resend REST API shape at https://mail-api.scribase.com, so the official resend npm SDK works against it with a new base URL and key — no new SDK to learn. Both patterns below run on Node (route handlers and Server Actions do not work on the Edge runtime with this SDK).

## Install and set a key

Install the resend package (there is no separate Scribase SDK), create a Scribase Mail API key in the dashboard, and store it as SCRIBASE_MAIL_KEY.

```sh
npm install resend
```

## A route handler

POST a recipient and subject to your own API route, which calls Scribase Mail server-side.

_app/api/send/route.ts_

```ts
// app/api/send/route.ts
import { Resend } from 'resend';

const resend = new Resend(process.env.SCRIBASE_MAIL_KEY, {
  baseUrl: 'https://mail-api.scribase.com',
});

export async function POST(request: Request) {
  const { to, subject, html } = await request.json();
  const { data, error } = await resend.emails.send({
    from: 'Acme <hello@mail.acme.com>',
    to,
    subject,
    html,
  });
  if (error) {
    return Response.json({ error: error.message }, { status: 400 });
  }
  return Response.json(data);
}
```

## Or a Server Action

The same SDK call works directly in a Server Action called from a form or client component.

_app/actions/send-email.ts_

```ts
// app/actions/send-email.ts
'use server';

import { Resend } from 'resend';

const resend = new Resend(process.env.SCRIBASE_MAIL_KEY, {
  baseUrl: 'https://mail-api.scribase.com',
});

export async function sendWelcomeEmail(toAddress: string) {
  const { data, error } = await resend.emails.send({
    from: 'Acme <hello@mail.acme.com>',
    to: [toAddress],
    subject: 'Welcome',
    html: '<p>Thanks for signing up.</p>',
  });
  if (error) throw new Error(error.message);
  return data;
}
```

## Verify a sending domain before going live

Real mail needs a verified domain on every plan. Add it in the dashboard or with POST /domains, publish the DKIM, SPF and DMARC records it returns, then verify; the check reads live DNS. An sk_test_ key sends without a verified domain while you build.

_Scribase Mail plans (USD a month), from the live /billing/plans endpoint_

| Plan | Price | Emails a month | Daily cap |
| --- | --- | --- | --- |
| Free | $0 | 3,000 emails a month | 100 emails a day |
| Pro | $20 | 50,000 emails a month | No daily cap |
| Scale | $90 | 150,000 emails a month | No daily cap |

## FAQ

**Do I need a Scribase-specific SDK for Next.js?**

No. There is no published @scribase/mail package. Use the official resend npm package with a baseUrl option or the RESEND_BASE_URL environment variable pointed at https://mail-api.scribase.com.

**Can I call this from the Edge runtime?**

The resend SDK targets Node; use the Node runtime for the route handler. Plain fetch() against the REST API works from either runtime.

**How do I send without a verified domain while developing?**

Create an sk_test_ key. Every send with it is simulated, never delivered and not metered, so the whole flow runs with no domain.

## Related

- [Scribase Mail overview](https://scribase.com/mail)
- [Scribase Mail docs](https://scribase.com/mail/docs)
- [Migrate from Resend](https://scribase.com/mail/migrate-from-resend)
- [Resend alternative](https://scribase.com/resend-alternative)
- [Send email from Node.js](https://scribase.com/mail/send-email-node)
- [Scribase backend](https://scribase.com/)