-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (31 loc) · 1.04 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import brevo from "@getbrevo/brevo";
const apiInstance = new brevo.TransactionalEmailsApi();
apiInstance.setApiKey(
brevo.TransactionalEmailsApiApiKeys.apiKey,
"yourapikey"
);
async function main() {
// db query
const user = {
name: "Juan Perez",
email: "[email protected]"
}
try {
const sendSmtpEmail = new brevo.SendSmtpEmail();
sendSmtpEmail.subject = "Hello world from brevo and Nodejs";
sendSmtpEmail.to = [
{ email: user.email, name: user.name },
// { email: "[email protected]", name: "Joe Mcmillan" },
];
sendSmtpEmail.htmlContent = `<html><body><h1>Hola ${user.name}</h1><p>This is a test email</p><button>Click me</button><a href='https://www.faztweb.com'>Go to my website</a></body></html>`;
sendSmtpEmail.sender = {
name: "FaztWeb",
email: "[email protected]",
};
const result = await apiInstance.sendTransacEmail(sendSmtpEmail);
console.log(result);
} catch (error) {
console.error(error);
}
}
main();