0.2.3 • Published 2 years ago
@techie04/xpresser-mailer v0.2.3
XpresserJs Mailer Plugin
A library to help you send mails.
This plugin makes use of nodemailer and aws-sdk ses.
MENU
Installation
npm i @techie04/xpresser-mailer
# OR
yarn add @techie04/xpresser-mailer
Add to plugins.json
{
"npm://@techie04/xpresser-mailer": true
}
Add to your project config.
({
// SMTP CONFIG
"mailer": {
provider: "SMTP", // SMTP
host: "", // SMTP Server Host
port: "", // SMTP Server Port
username: "", // SMTP Server Username
password: "", // SMTP Server Password
fromEmail: "no-reply@example.com" // From email
},
// AWS CONFIG
"mailer": {
provider: "AWS", // AWS
region: "", // AWS Server Region
fromEmail: "no-reply@example.com", // From email
// AWS credentials
AWS_ACCESS_KEY_ID: "",
AWS_SECRET_ACCESS_KEY: ""
},
})
Usage
In your controller or anywhere in your project.
const { sendMail } = require("@techie04/xpresser-mailer");
(async () => {
// array of attachments
const attachments = [
{
// filename (optional)
filename: "techieoriname.png",
// file path or url
path: path.join(__dirname, "..", "TechieOriname.png")
}
]
await sendMail(
"example@example.com", // to email
"testing subject", // message subject
"my message here", // message body
"text", // message format ("html" or "text")
attachments // optional field
);
});
Typescript support
import { AttachmentType, sendMail } from "@techie04/xpresser-mailer";
// array of attachments
const attachments: AttachmentType[] = [
{
// filename (optional)
filename: "techieoriname.png",
// file path or url
path: path.join(__dirname, "..", "TechieOriname.png")
}
];
await sendMail(
"example@example.com",
"testing subject",
"my message here",
"text",
attachments // optional field
);