EmailProvidersResend

Resend

Send emails using the Resend API with @visulima/email

Resend Provider

The Resend provider allows you to send emails through the Resend API, a modern email API for developers.

Runtime Support: Universal (Node.js, Deno, Bun, Cloudflare Workers)

Setup

import { createMail } from "@visulima/email";
import { resendProvider } from "@visulima/email/providers/resend";

const mail = createMail(
    resendProvider({
        apiKey: process.env.RESEND_API_KEY!,
    }),
);

Configuration

The ResendConfig interface extends BaseConfig with the following options:

OptionTypeRequiredDefaultDescription
apiKeystringYes-Your Resend API key (starts with re_)
endpointstringNohttps://api.resend.comCustom API endpoint
debugbooleanNofalseEnable debug logging
loggerConsoleNo-Custom logger instance
retriesnumberNo3Number of retry attempts on failure
timeoutnumberNo30000Request timeout in milliseconds

Basic Usage

import { MailMessage } from "@visulima/email";

const message = new MailMessage()
    .to("user@example.com")
    .from("sender@example.com")
    .subject("Hello from Resend")
    .html("<h1>Hello World</h1>");

const result = await mail.send(message);

Provider-Specific Email Options

The Resend provider supports additional options through ResendEmailOptions:

Tags

Tags can be used for categorizing emails. Tag names and values must only contain ASCII letters, numbers, underscores, or dashes. Tag names have a max length of 256 characters.

import type { ResendEmailOptions } from "@visulima/email/providers/resend";

const options: ResendEmailOptions = {
    from: { email: "sender@example.com" },
    to: { email: "user@example.com" },
    subject: "Tagged email",
    html: "<h1>Hello</h1>",
    tags: [
        { name: "category", value: "welcome" },
        { name: "environment", value: "production" },
    ],
};

Scheduled Sending

const options: ResendEmailOptions = {
    from: { email: "sender@example.com" },
    to: { email: "user@example.com" },
    subject: "Scheduled email",
    html: "<h1>Hello</h1>",
    scheduledAt: new Date("2025-01-15T10:00:00Z"),
};

Template-Based Emails

const options: ResendEmailOptions = {
    from: { email: "sender@example.com" },
    to: { email: "user@example.com" },
    subject: "Template email",
    html: "",
    templateId: "tmpl_xxx",
    templateData: {
        name: "John",
        company: "Acme",
    },
};

Supported Features

FeatureSupported
AttachmentsYes
Batch SendingYes
Custom HeadersYes
HTMLYes
Reply-ToYes
SchedulingYes
TaggingYes
TemplatesYes
TrackingYes

Additional Methods

Retrieve Email

You can retrieve email details by ID:

const provider = resendProvider({ apiKey: "re_xxx" });
const result = await provider.getEmail("email-id");

Validate Credentials

const isValid = await provider.validateCredentials();
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues