Mailer is a Node.js application for sending bulk emails using Nodemailer, CSV parsing, and HTML templates. This script reads recipient data from a CSV file, manages email attachments, and tracks sent emails to avoid duplication. Here's an overview of its functionality and setup:
- Bulk Email Sending: Send emails in bulk to recipients listed in a CSV file.
- Attachment Support: Include attachments dynamically from a specified directory.
- Template-based Emails: Use HTML templates for composing emails with dynamic content.
- Email Tracking: Keeps track of sent emails to prevent sending duplicates.
- Delay Between Emails: Configurable delay between each email to comply with email service provider limits.
To use the Mailer script, follow these steps:
-
Clone the Repository:
git clone https://github.com/Fedot-Compot/mailer.git cd mailer
-
Install Dependencies:
npm install
-
Set Up Environment Variables:
Create a
.env
file in the root directory of the project and add the following environment variables:[email protected] PASSWORD=your_email_password SENDER_NAME=Your Name MAX_EMAILS=100 # Number of maximum emails to send WAIT_BETWEEN_MAILS=5 # Wait time in seconds between each email
Ensure
subject.txt
andtemplate.html
files are placed in thedata/
directory. Attachments should also be placed indata/attachments/
directory. -
Run the Script:
node index.js
This will start sending emails to recipients listed in
data/recipients.csv
.
- SMTP Configuration: Modify the
transporter
object inindex.js
to match your SMTP server settings (e.g., host, port, secure mode). - Email Content: Customize
subject.txt
andtemplate.html
(for base64 you can use this website) to tailor the subject and body of your emails.
- Ensure Node.js and npm are installed on your system before running the script.
- Handle sensitive information like email credentials securely using environment variables.
- Adjust
MAX_EMAILS
andWAIT_BETWEEN_MAILS
according to your email service provider's sending limits and policies.
- Nodemailer: For providing an easy-to-use module for sending emails in Node.js.
- CSV Parse: For facilitating the parsing of CSV files in JavaScript.
Feel free to extend and customize this script according to your specific requirements. For any issues or feature requests, please open an issue on GitHub.