emailer-kit
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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.

NPM NPM NPM NPM

✨ 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@example.com",
    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

⭐️ Show Your Support

Give a ⭐️ if this project helped you!

Package Sidebar

Install

npm i emailer-kit

Weekly Downloads

115

Version

0.1.2

License

MIT

Unpacked Size

9.29 kB

Total Files

8

Last publish

Collaborators

  • rifatsaown