How to integrate SendinBlue using Nodejs
Link to the github repo click here (SIB)
SendinBlue (SIB) is one of the smartest SaaS solutions for digital marketing and offers a cloud-based option. The company was founded in 2007 by Armand Thiberge and Kapil Sharma. The company has four offices globally, located in Paris, Delhi, Seattle, and Berlin with headquarters in Paris.
Integration Using Nodejs
First of all,
Create an account with Sendinblue. One can go for free plan if testing or paid version.
After you have logged into your account, goto Dashboard, click on your profile, navigate & click on ["SMTP & API"] option.
Navigate to [Create a New API Key] at your top-right of the dashboard, click and create an API key for your project. Open your IDE for your project folder and follow these steps:
npm init -y
npm i sib-api-v3-sdk dotenv
Open
.env file
Type
API_KEY: "Insert the api_key copied when you created your account"
Create an index.js file and copy the following code :
const Sib = require('sib-api-v3-sdk')
require('dotenv').config()
const client = Sib.ApiClient.instance
const apiKey = client.authentications['api-key']
apiKey.apiKey = process.env.API_KEY
const sender = {
name: 'Sender's Name',
email: 'Sender's email goes here',
// Sender's name: 'Emmanuel Edeh',
}
const receivers = [
{
email: 'recepient email address goes here',
// Client Email
},
]
const transactionalEmailApi = new Sib.TransactionalEmailsApi()
transactionalEmailApi.sendTransacEmail({
subject: 'Subscribe to PMT Tech Coding Class to become a developer',
sender,
to: receivers,
textContent: `PMT Tech Coding will teach you how to become a developer with Mentorship exclusive.`,
})
.then(console.log)
.catch(console.log)
After the above is pasted in your index.js open your terminal and type
node index.js
You will receive a reply that looks like this;
└─$ node index.js
exports {
messageId: '<202206241425.81240014658@smtp-relay.mailin.fr>'
}