npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

auto-email-sender

v1.1.1

Published

A simple package to send emails with SMTP using an HTML template and data from an Excel sheet

Downloads

221

Readme

Auto Email Sender

Auto Email Sender is a simple Node.js package that allows you to send emails using an SMTP server. It supports sending emails with customizable HTML content and data extracted from an Excel sheet. This package is ideal for bulk email sending where email content is dynamic and personalized for each recipient.

Features

  • Send emails using any SMTP server.
  • Supports HTML templates for email content with dynamic placeholders.
  • Extracts recipient information (e.g., email addresses, names, and other data) from an Excel sheet.
  • Easy-to-use API with minimal configuration required.

Installation

Install the package via npm:

npm install auto-email-sender

Usage

Here’s how you can use the auto-email-sender package in your Node.js project:

Step 1: Prepare Your Excel File

Ensure your Excel file contains the following columns:

  • Email (the recipient's email address)
  • Name (the recipient's name)
  • Other columns (optional data to be included in the email)

Example Excel structure:

| Email | Name | Data1 | Data2 | |---------------------|-----------|-------|-------| | [email protected] | Aniket Subudhi | Info1 | Info2 | | [email protected] | Swagat | Info3 | Info4 |

Step 2: Create an HTML Template

Create an HTML file for the email content. Use placeholders in the form of {{placeholder_name}} for dynamic content.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Email Template</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            color: #333;
            margin: 0;
            padding: 20px;
        }
        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .header {
            font-size: 24px;
            font-weight: bold;
        }
        .content {
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">Hello {{name}},</div>
        <div class="content">
            This is a dynamic email message.<br>
            Here is some additional data: {{other1}}, {{other2}}.
        </div>
    </div>
</body>
</html>

Step 3: Use the Package in Your Project

Here’s an example of how to use the package:

const AutoEmailSender = require('auto-email-sender');

// SMTP configuration
const smtpConfig = {
    host: 'smtp.example.com',
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
        user: '[email protected]',
        pass: 'your-email-password',
    },
};

// Initialize the AutoEmailSender with the Excel file, SMTP config, and column names
const emailSender = new AutoEmailSender('path/to/your/excel/file.xlsx', smtpConfig, 'Email', 'Name');

// Set the subject and path to the HTML template
const subject = 'Your Email Subject';
const templatePath = 'path/to/email_template.html';

// Send emails for all rows in the specified columns
emailSender.sendEmailsForColumn(subject, templatePath);

Step 4: Run Your Script

To send the emails, simply run your Node.js script:

node your_script.js

API Documentation

AutoEmailSender(filePath, smtpConfig, emailColumnName, nameColumnName)

  • filePath: Path to the Excel file containing recipient data.
  • smtpConfig: SMTP configuration object for nodemailer. Must include host, port, secure, and auth properties.
  • emailColumnName: The name of the column containing email addresses.
  • nameColumnName: The name of the column containing recipient names.

sendEmailsForColumn(subject, templatePath)

  • subject: Subject of the email.
  • templatePath: Path to the HTML template file.

Example SMTP Configuration

const smtpConfig = {
    host: 'smtp.example.com', // Replace with your SMTP server
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
        user: '[email protected]',
        pass: 'your-email-password',
    },
};

License

This project is licensed under the ISC License.

Author

Aniket Subudhi

Contributions

Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.

Acknowledgments

  • Nodemailer - The Node.js module used for sending emails.
  • xlsx - The library used to parse Excel files.
  • fs-extra - The library used for file system operations.