Provider Integration
Provider recipes
Send compiled output with SMTP2GO, Bird, Mailchimp, HubSpot, ActiveCampaign and Nodemailer.
The common shape
Every provider needs the same three things from the compiler: an HTML body, a plain-text body and a subject. These recipes show the idea; check each provider's current API reference for exact field names and authentication.
Nodemailer (SMTP)
import nodemailer from 'nodemailer'
import { compileNewsletter } from 'newsletter-builder-react'
const { html, text, subject } = compileNewsletter(doc, { variables })
const transport = nodemailer.createTransport(process.env.SMTP_URL)
await transport.sendMail({ from, to, subject, html, text })SMTP2GO and Bird
Both expose SMTP relays and HTTP APIs. The SMTP route works with the Nodemailer example above; with an HTTP API, map html and text onto the provider's HTML and text body fields.
await fetch(process.env.PROVIDER_ENDPOINT!, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${process.env.PROVIDER_KEY}` },
body: JSON.stringify({
sender: from,
to: [to],
subject,
html_body: html,
text_body: text,
}),
})Mailchimp, HubSpot and ActiveCampaign
These platforms store a campaign template. Compile without variables so merge tags survive, convert tags to the platform's syntax, then upload the HTML through their template or campaign API (or paste it into their custom HTML editor).
const tags = [
{ name: 'firstName', label: 'First name', token: '*|FNAME|*' },
]
const { html } = compileNewsletter(doc)
const mailchimpHtml = html.replaceAll('{{firstName}}', '*|FNAME|*')