EmailProvidersBrevo

Brevo

Send emails using the Brevo (formerly Sendinblue) API with @visulima/email

Brevo Provider

The Brevo provider allows you to send emails through the Brevo API, formerly known as Sendinblue.

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

Setup

import { createMail } from "@visulima/email";
import { brevoProvider } from "@visulima/email/providers/brevo";

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

Configuration

The BrevoConfig interface extends BaseConfig with the following options:

OptionTypeRequiredDefaultDescription
apiKeystringYes-Your Brevo API key
endpointstringNohttps://api.brevo.com/v3Custom API endpoint
hardValidationbooleanNofalseIf true, replyTo arrays are rejected. If false, the first address is used.
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 Brevo")
    .html("<h1>Hello World</h1>");

const result = await mail.send(message);

Provider-Specific Email Options

The Brevo provider supports additional options through BrevoEmailOptions:

Scheduled Sending

The scheduledAt option accepts an ISO 8601 string or a Unix timestamp in seconds (not milliseconds).

import type { BrevoEmailOptions } from "@visulima/email/providers/brevo";

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

Template-Based Emails

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

Batch Sending

const options: BrevoEmailOptions = {
    from: { email: "sender@example.com" },
    to: { email: "user@example.com" },
    subject: "Batch email",
    html: "<h1>Hello</h1>",
    batchId: "batch-123",
};
OptionTypeDescription
tagsstring[]Tags for categorization
templateIdnumberBrevo template ID
templateParamsRecord<string, unknown>Template parameters
scheduledAtstring | numberISO 8601 date string or Unix timestamp (seconds)
batchIdstringBatch ID for batch sending
replyToEmailAddress | EmailAddress[]Reply-to address (only one allowed by Brevo)

Supported Features

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

Additional Methods

Retrieve Email

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

Important Notes

  • Brevo only supports a single reply-to address. If an array is provided and hardValidation is false (default), the first address is used. If hardValidation is true, an error is returned.
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