> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.brevo.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.brevo.com/_mcp/server.

Use this Node.js code and enter your own details to run the SMTP relay.

### Install nodemailer in your Node project

Run this command in your working directory:

```javascript
npm install nodemailer
```

### Include the library in your working class

```javascript
const nodemailer = require("nodemailer");
```

### Declare your SMTP credentials

Specify your Brevo credentials to establish a connection between our server and your application. Use the `createTransport` object to define these values.

```javascript
  let transporter = nodemailer.createTransport({
    host: "smtp-relay.brevo.com",
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: "example@brevo.com", // generated ethereal user
      pass: "xxxxxxxxx", // generated ethereal password
    },
  });
```

### Compose your email object

Specify the content and metadata of the email message to send through the transporter object. This example uses text content only, but you can also use a predefined `templateId`.

```javascript


  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: '"Joe" example@brevo.com', // sender address
    to: "hi@mail.com", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello {{ contact.FIRSTNAME }} , This is an SMTP message with customizations", // plain text body
  });


```

### Trigger your email

Specify the content and metadata of the email message to send through the transporter object. This example uses text content only, but you can also use a predefined `templateId`. The full example is below.

```javascript
const nodemailer = require("nodemailer");

async function main() {
  

  // create reusable transporter object using the default SMTP transport
  let transporter = nodemailer.createTransport({
    host: "smtp-relay.brevo.com",
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: "user@brevo.com", // generated brevo user
      pass: "xxxxxxxxx", // generated brevo password
    },
  });

  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: '"mauricio@brevo.com', // sender address
    to: "john@domain.com", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello {{ contact.FIRSTNAME }} , This is an SMTP message with customizations", // plain text body
  });

  console.log("Message sent: %s", info.messageId);
  // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
}

main().catch(console.error);
```

Note: this example adds customizations to your SMTP email. It uses the contact's attributes if the contact exists in Brevo. Run this JS code from the command line, or use the [Send a Transactional Email](/reference/send-transac-email) API endpoint.