Invia email da Node.js
Installa @getbrevo/brevo, crea un BrevoClient con la tua chiave API e chiama sendTransacEmail, oppure punta Nodemailer al relay SMTP di Brevo.

Come funziona
npm install @getbrevo/brevo
import { BrevoClient } from '@getbrevo/brevo';
const brevo = new BrevoClient({ apiKey: 'your-api-key' });
const result = await brevo.transactionalEmails.sendTransacEmail({
subject: 'Hello from Brevo!',
htmlContent: '<html><body><p>Hello,</p><p>This is my first transactional email.</p></body></html>',
sender: { name: 'Alex from Brevo', email: '[email protected]' },
to: [{ email: '[email protected]', name: 'John Doe' }],
});
console.log('Email sent. Message ID:', result.messageId);
npm install nodemailer
const nodemailer = require("nodemailer");
let transporter = nodemailer.createTransport({
host: "smtp-relay.brevo.com",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: "[email protected]", // generated brevo user
pass: "xxxxxxxxx", // generated brevo password
},
});
curl --request POST \
--url https://api.brevo.com/v3/smtp/email \
--header 'accept: application/json' \
--header 'api-key:YOUR_API_KEY' \
--header 'content-type: application/json' \
--data '{
"sender":{
"name":"Alex from Brevo",
"email":"[email protected]"
},
"to":[
{
"email":"[email protected]",
"name":"John Doe"
}
],
"subject":"Hello from Brevo!",
"textContent":"Hello. This is my first transactional email sent from Brevo."
}'
Chiedi al tuo agente IA
Dai questo prompt a un agente IA collegato al server Brevo MCP.
Before I send email from my Node.js app, check that I have a verified sender and an authenticated sending domain. List what is missing.
Perché funziona
Email da Node.js con Brevo: i fatti
API. Invia un'email transazionale con POST https://api.brevo.com/v3/smtp/email e la tua chiave API nell'header api-key.
Relay SMTP. L'host è smtp-relay.brevo.com. Usa le porte 587 o 2525, oppure la porta 465 con crittografia SSL o TLS. Per le connessioni al relay SMTP usa una chiave SMTP, non una chiave API.
Piano Free. Il piano Free include 300 invii email al giorno e fino a 100.000 contatti archiviati. Tutti i piani Brevo ti danno accesso alle API RESTful, a SMTP e ai webhook in uscita per le email transazionali.
Hosting in UE. I server di hosting su cui Brevo elabora e archivia i propri database si trovano tutti nell'Unione Europea. Brevo utilizza OVH in Francia e Germania e i dati sono archiviati su Google Cloud in Belgio.