Prerequisites

To get the most out of this guide, you’ll need to:

1. Install

Get the Resend Node.js SDK.

2. Send email using HTML

yarn rw g function send

The easiest way to send an email is by using the html parameter.

api/src/functions/send/send.ts
import { Resend } from 'resend';
import type { APIGatewayEvent, Context } from 'aws-lambda';

const resend = new Resend('re_123456789');

export const handler = async (event: APIGatewayEvent, context: Context) => {
  const { data, error } = await resend.emails.send({
    from: 'Acme <onboarding@resend.dev>',
    to: ['delivered@resend.dev'],
    subject: 'hello world',
    html: '<strong>it works!</strong>',
  });

  if (error) {
    return {
      statusCode: 500,
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ error }),
    };
  }

  return {
    statusCode: 200,
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ data }),
  };
};

3. Try it yourself

Redwood.js Example

See the full source code.

Was this page helpful?