Node.js example
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:
Include the library in your working class
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.
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.
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.
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 API endpoint.