import express, { Request, Response } from "express";
import { Emailr } from "emailr";
const app = express();
const emailr = new Emailr("em_xxxxxxxxx");
app.get("/", async (req: Request, res: Response) => {
const { data, error } = await emailr.emails.send({
from: "Acme <[email protected]>",
to: ["[email protected]"],
subject: "hello world",
html: "<strong>it works!</strong>",
});
if (error) {
return res.status(400).json({ error });
}
res.status(200).json({ data });
});
app.listen(3000, () => {
console.log("Listening on http://localhost:3000");
});