Skip to main content
To send an email using Resend, use the resend SDK. Set your Resend API key as an environment secret named RESEND_API_KEY.
import * as BunnySDK from "@bunny.net/edgescript-sdk";
import { Resend } from "https://esm.sh/resend";
import process from "node:process";

const resend = new Resend(process.env.RESEND_API_KEY);

BunnySDK.net.http.serve(async (req) => {
  try {
    await resend.emails.send({
      from: "[email protected]",
      to: "[email protected]",
      subject: "Welcome to Bunny Edge Scripting!",
      text: "This email was sent directly from the edge.",
    });
    return new Response("Email sent successfully!");
  } catch (error) {
    console.error(error);
    return new Response("Failed to send email.", { status: 500 });
  }
});