nodejs-mail-sender
v1.0.6
Published
Send emails easily usiing this library
Downloads
23
Maintainers
Readme
Nodejs-mail-Sender
Send emails easily usiing this library
Installation
npm i nodejs-mail-sender --save
Setup environment vairables
Inside a .env file, add the following values. Refer to the demo/.env.example
# You can generate dummy credentials at https://ethereal.email/create
[email protected]
SMTP_HOST=smtp.ethereal.email
SMTP_PORT=587
SMTP_SECURE=false
[email protected]
SMTP_PASSWORD=j8HgEVCFTn8mC5mzfN
SMTP_TLS_CIPHERS=false
Usage
import { Mailer } from "../dist/index.js";
const mailerUsingStringConf = async () => {
try {
console.log("MAILER:", Mailer);
// You can generate dummy credentials at https://ethereal.email/create
// sample stmp config url = "smtps://username:[email protected]/?pool=true"
let mailer = new Mailer(`smtp://[email protected]:[email protected]`);
console.log("mailer in demo:", mailer);
const mailOptions = {
to: "[email protected]",
subject: "Test subject",
text: "test text",
}
await mailer.sendMail(mailOptions);
} catch(err) {
console.error("err", err);
}
}
mailerUsingStringConf();
const mailerUsingOptions = async () => {
try {
let mailer = new Mailer();
console.log("mailer in demo:", mailer);
const mailOptions = {
to: "[email protected]",
subject: "Test subject",
text: "test text",
}
await mailer.sendMail(mailOptions);
} catch(err) {
console.error("err", err);
}
}
mailerUsingOptions();
Todo:
- Unit test coverage
- Test with popular email service providers like Google, Yahoo
- Add a workaround to append emails sent to
Sent Items
folder through bcc
License:
MIT © Ramu Narasinga