Node.js
Express
Get started with sending emails in Express using Dhesend Node.js SDK.
Prerequisites
To get the most out of this guide, you’ll need to:
2. Send email using html
The easiest way to send an email is by using the html parameter.
1import express, { Request, Response } from "express";
2import Dhesend from "dhesend";
3
4const app = express();
5const dhesend = new Dhesend("dhe_fdd03c4eb1");
6
7app.post("/send-email", async (req: Request, res: Response) => {
8 const { data, error } = await dhesend.emails.send({
9 from: "Dhesend <example@domain.com>",
10 to: ['example@dhesend.com'],
11 subject: 'Welcome to Dhesend',
12 htmlBody: '<strong>Have a nice day!</strong>',
13 });
14
15 if (error) {
16 return res.status(400).json({ error });
17 };
18
19 res.status(200).json({ data });
20});
21
22app.listen(3000, () => {
23 console.log("Listening on http://localhost:3000");
24});On this page