ExpressJs
To use easymailer with expressjs
- in your express app, install the
easymailer
package
npm i @xeuxdev/easymailer
import the easymailer package into your file
ESM
import { sendMail } from "@xeuxdev/easymailer"
CJS
const { sendMail } = require("@xeuxdev/easymailer")
-
Don't forget to add your environment variables, to see how you can do that go to usage
-
use the
sendMail()
function
app.get("/", async (req, res) => {
const response = await sendMail({
message: {
from: "xeuxdev Express example",
html: "Hey this is a message from easymailer using express",
bcc: [
"email1@gmail.com",
"wmail2@gmail.com",
"email3@gmail.com",
"email4@gmail.com",
],
subject: "Test Email From Express",
},
transport: {
service: "gmail",
},
})
res.status(200).json(response)
})