Last active
December 4, 2024 16:42
-
-
Save devlopersabbir/91dcbabaf74f7f0a7acf37f91c41ac03 to your computer and use it in GitHub Desktop.
brevo-mail-send
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// type must be (modue) | |
import * as Brevo from "@getbrevo/brevo"; | |
import express from "express"; | |
const api_key = "YOUR_API_KEY_HERE"; | |
const client = new Brevo.TransactionalEmailsApi(); | |
client.setApiKey(0, api_key); | |
const sendSmtpEmail = new Brevo.SendSmtpEmail(); | |
sendSmtpEmail["subject"] = "this is subject"; | |
sendSmtpEmail["htmlContent"] = | |
"<html><body><h1>this is cutom email from sabbir</h1></body></html>"; | |
sendSmtpEmail["sender"] = { | |
name: "Sabbir Hossain Shuvo", | |
email: "[email protected]", | |
}; | |
sendSmtpEmail["to"] = [ | |
{ email: "[email protected]", name: "ST Sabbir" }, | |
]; | |
sendSmtpEmail["headers"] = { "Some-Custom-Name": "unique-id-1234" }; | |
const app = express(); | |
app.use(express.json()); | |
app.get("/", async (_, res) => { | |
try { | |
const data = await client.sendTransacEmail(sendSmtpEmail); | |
res.status(200).json({ message: "sended!", data }); | |
} catch (err) { | |
console.log(err); | |
res.send("fail"); | |
} | |
}); | |
app.listen(5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment