emailer-kit
v0.1.2
Published
emailer-kit is a versatile and easy-to-use Node.js utility that simplifies email sending using Nodemailer. With a streamlined interface, it provides a set of functions to effortlessly send HTML emails, making it an ideal toolkit for integrating email func
Downloads
16
Maintainers
Readme
emailer-kit
emailer-kit is a Node.js utility that simplifies email sending using Nodemailer. It provides an easy-to-use interface for sending HTML emails with various configurations.
✨ Features
- 📧 Effortlessly Send HTML Emails
- 🌐 Compatible with Various Email Service Providers
- 🛠️ Simplifies Nodemailer Configuration
- 📦 Lightweight and Easy to Use
- 📚 Supports ES6 Modules and CommonJS
- 📜 Written in TypeScript
- 🗃️ Support for Attachments (New)
📦 Installation
npm install emailer-kit
# or
yarn add emailer-kit
⚙️ Configuration
emailer-kit uses Nodemailer to send emails. You can configure Nodemailer by setting the following environment variables.
Environment Variables
Create a .env
file in the root of your project and add:
NODEMAIL_SERVICE=[email service provider, e.g., 'outlook', 'gmail', 'yahoo', etc.]
NODEMAIL_EMAIL=[your email address]
NODEMAIL_PASSWORD=[your email password]
Note: If you are using Gmail, you need an app password. You can create an app password in your Google account settings under the security tab.
🚀 Usage
import { emailer } from "emailer-kit";
// For CommonJS
// const { emailer } = require("emailer-kit");
async function sendTestEmail() {
// emailerOptions is an object that contains the email options
const emailerOptions = {
email: "[email protected]",
subject: "Test Subject",
htmlContent: "<p>This is a test email.</p>",
file: { // Attachment is optional
path: "path/to/your/file.pdf",
name: "file.pdf" // Name is optional
}
};
try {
const info = await emailer(emailerOptions);
console.log("Email sent:", info.response);
} catch (error) {
console.error("Error sending email:", error);
}
}
sendTestEmail();
🤝 Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change. Make sure to update tests as appropriate.
👤 Author
Md Rifat Hossen Saown
- Website: rifatsaown.netlify.app
- GitHub: @rifatsaown
- LinkedIn: Md Rifat Hossen Saown
- Facebook: Md Rifat Hossen Saown
⭐️ Show Your Support
Give a ⭐️ if this project helped you!