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 πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

@prathammahajan/multi-email-sender

v1.0.0

Published

πŸš€ Enterprise-grade Node.js email automation with intelligent retry logic, smart rate limiting, template engine, and comprehensive analytics. Perfect for bulk campaigns, transactional emails, and marketing automation.

Readme

πŸš€ Multi Email Sender

The Ultimate Node.js Email Automation Solution

npm version License: MIT Node.js Downloads

GitHub stars GitHub forks GitHub watchers


🎯 What Makes This Special?

Transform your email operations with our enterprise-grade solution that combines intelligent automation, smart analytics, and bulletproof reliability. Whether you're sending 10 emails or 10,000, we've got you covered!

🌟 Why Developers Love Us

  • 🧠 Smart Retry Logic - Never lose an email again with intelligent exponential backoff
  • ⚑ Adaptive Rate Limiting - Automatically adjusts to your email provider's limits
  • πŸ“Š Real-time Analytics - Track success rates, performance metrics, and delivery insights
  • 🎨 Template Engine - Create personalized emails with dynamic content
  • πŸ›‘οΈ Enterprise Security - Built with production-grade error handling and validation
  • πŸ“ˆ Scalable Architecture - Handles everything from startups to enterprise workloads

πŸš€ Quick Start (30 seconds)

npm install @prathammahajan/multi-email-sender
import { EmailSender } from '@prathammahajan/multi-email-sender';

// 🎯 Initialize with your email provider
const sender = new EmailSender({
  email: {
    service: 'gmail',
    auth: {
      user: '[email protected]',
      pass: 'your-app-password' // Use app password for Gmail
    }
  }
});

// πŸ“§ Send to multiple recipients instantly
const results = await sender.sendToMultiple(
  ['[email protected]', '[email protected]'],
  {
    subject: 'πŸŽ‰ Welcome to Our Platform!',
    html: '<h1>Hello there!</h1><p>Thanks for joining us!</p>'
  }
);

console.log(`βœ… Sent ${results.filter(r => r.success).length} emails successfully!`);

That's it! Your emails are sent with automatic retry logic, rate limiting, and comprehensive logging. πŸŽ‰


🎨 Interactive Features Showcase

🧠 Smart Retry Logic

// Automatically retries failed emails with exponential backoff
const sender = new EmailSender({
  options: {
    maxRetries: 5,        // Try up to 5 times
    retryDelay: 1000,     // Start with 1 second delay
    enableLogging: true   // Track every attempt
  }
});

⚑ Adaptive Rate Limiting

// Automatically adjusts to your provider's limits
const sender = new EmailSender({
  rateLimit: {
    enabled: true,
    maxEmailsPerMinute: 10,  // Gmail-friendly
    maxEmailsPerHour: 100    // Respectful limits
  }
});

🎨 Dynamic Templates

// Create personalized emails with ease
const recipients = [
  { email: '[email protected]', name: 'John', company: 'Tech Corp' },
  { email: '[email protected]', name: 'Jane', company: 'Design Studio' }
];

const emailContent = {
  subject: 'Hello {{name}} from {{company}}!',
  html: `
    <h1>Welcome {{name}}!</h1>
    <p>We're excited to have you from <strong>{{company}}</strong> join our community.</p>
    <p>Best regards,<br>The Team</p>
  `,
  template: {
    name: 'welcome',
    variables: { name: '{{name}}', company: '{{company}}' }
  }
};

await sender.sendToMultiple(recipients, emailContent);

πŸ“Š Real-time Analytics

// Get comprehensive insights
const stats = sender.getStatistics();
console.log(`
πŸ“ˆ Email Analytics:
βœ… Success Rate: ${((stats.totalSent / (stats.totalSent + stats.totalFailed)) * 100).toFixed(1)}%
πŸ“§ Total Sent: ${stats.totalSent}
⏱️  Avg Duration: ${Math.round(stats.averageDuration)}ms
πŸ”„ Total Attempts: ${stats.totalAttempts}
`);

πŸ› οΈ Configuration Made Simple

πŸ“§ Email Provider Setup

const gmailSender = new EmailSender({
  email: {
    service: 'gmail',
    auth: {
      user: '[email protected]',
      pass: 'your-app-password' // Generate in Google Account settings
    }
  },
  options: {
    dailyLimit: 100,           // Gmail's recommended limit
    delayBetweenEmails: 2000,  // 2 seconds between emails
    maxRetries: 3
  },
  rateLimit: {
    maxEmailsPerMinute: 10,
    maxEmailsPerHour: 100
  }
});

πŸ’‘ Pro Tip: Enable 2-factor authentication and use app passwords for better security!

const outlookSender = new EmailSender({
  email: {
    service: 'hotmail',
    auth: {
      user: '[email protected]',
      pass: 'your-password'
    }
  },
  options: {
    dailyLimit: 300,           // Outlook allows more
    delayBetweenEmails: 1000,  // Faster sending
    maxRetries: 3
  },
  rateLimit: {
    maxEmailsPerMinute: 20,
    maxEmailsPerHour: 200
  }
});
const customSender = new EmailSender({
  email: {
    service: 'custom',
    auth: {
      user: '[email protected]',
      pass: 'your-smtp-password'
    },
    host: 'smtp.yourdomain.com',
    port: 587,
    secure: false
  },
  options: {
    dailyLimit: 500,           // Check with your provider
    delayBetweenEmails: 500,   // Custom providers often allow faster sending
    maxRetries: 5
  },
  rateLimit: {
    maxEmailsPerMinute: 30,
    maxEmailsPerHour: 500
  }
});

🎯 Real-World Use Cases

πŸ›’ E-commerce Order Confirmations

// Send personalized order confirmations
const orderEmails = orders.map(order => ({
  email: order.customerEmail,
  name: order.customerName,
  orderId: order.id,
  total: order.total,
  items: order.items
}));

const emailContent = {
  subject: 'πŸŽ‰ Order Confirmation #{{orderId}}',
  html: `
    <h1>Thank you {{name}}!</h1>
    <p>Your order #{{orderId}} has been confirmed.</p>
    <p><strong>Total: ${{total}}</strong></p>
    <p>We'll send you tracking information soon!</p>
  `,
  template: {
    name: 'order-confirmation',
    variables: { name: '{{name}}', orderId: '{{orderId}}', total: '{{total}}' }
  }
};

await sender.sendToMultiple(orderEmails, emailContent);

πŸ“§ Newsletter Campaigns

// Send newsletters with attachments
const newsletterContent = {
  subject: 'πŸ“° Weekly Newsletter - {{date}}',
  html: newsletterHTML,
  attachments: [
    { filename: 'newsletter.pdf', path: './newsletters/weekly.pdf' }
  ],
  template: {
    name: 'newsletter',
    variables: { date: new Date().toLocaleDateString() }
  }
};

// Process in batches for large lists
const batchSize = 50;
for (let i = 0; i < subscribers.length; i += batchSize) {
  const batch = subscribers.slice(i, i + batchSize);
  await sender.sendToMultiple(batch, newsletterContent);
  
  // Add delay between batches
  await new Promise(resolve => setTimeout(resolve, 5000));
}

πŸ”” Transactional Notifications

// Send system notifications
const notifications = [
  { email: '[email protected]', type: 'system', message: 'Server backup completed' },
  { email: '[email protected]', type: 'account', message: 'Password changed successfully' }
];

for (const notification of notifications) {
  const emailContent = {
    subject: `πŸ”” ${notification.type.charAt(0).toUpperCase() + notification.type.slice(1)} Notification`,
    text: notification.message,
    priority: 'high'
  };
  
  await sender.sendSingle(notification.email, emailContent);
}

πŸ“Š Advanced Features

🧠 Intelligent Error Handling

// Automatic error categorization and handling
const results = await sender.sendToMultiple(recipients, emailContent);

results.forEach(result => {
  if (!result.success) {
    switch (result.error) {
      case 'authentication':
        console.log('πŸ” Auth issue - check credentials');
        break;
      case 'rate_limit':
        console.log('⏱️ Rate limited - will retry automatically');
        break;
      case 'network':
        console.log('🌐 Network issue - retrying with backoff');
        break;
      default:
        console.log('❌ Other error:', result.error);
    }
  }
});

πŸ“ˆ Performance Monitoring

// Get detailed performance insights
const stats = sender.getStatistics();
const logs = sender.getLogs();

console.log(`
πŸ“Š Performance Report:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ πŸ“§ Emails Sent: ${stats.totalSent.toString().padEnd(20)} β”‚
β”‚ ❌ Failed: ${stats.totalFailed.toString().padEnd(23)} β”‚
β”‚ ⏱️  Avg Time: ${Math.round(stats.averageDuration).toString().padEnd(18)}ms β”‚
β”‚ πŸ”„ Total Attempts: ${stats.totalAttempts.toString().padEnd(15)} β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ˆ Success Rate: ${((stats.totalSent / (stats.totalSent + stats.totalFailed)) * 100).toFixed(1)}%
🎯 Error Breakdown:`, stats.errorBreakdown);

πŸ”„ Batch Processing with Progress

// Process large lists with progress tracking
const processLargeList = async (recipients, emailContent) => {
  const batchSize = 100;
  const totalBatches = Math.ceil(recipients.length / batchSize);
  
  for (let i = 0; i < recipients.length; i += batchSize) {
    const batchNumber = Math.floor(i / batchSize) + 1;
    const batch = recipients.slice(i, i + batchSize);
    
    console.log(`πŸ“¦ Processing batch ${batchNumber}/${totalBatches} (${batch.length} recipients)...`);
    
    const results = await sender.sendToMultiple(batch, emailContent);
    const successful = results.filter(r => r.success).length;
    
    console.log(`βœ… Batch ${batchNumber} completed: ${successful}/${batch.length} successful`);
    
    // Show progress bar
    const progress = Math.round((batchNumber / totalBatches) * 100);
    console.log(`πŸ“Š Progress: [${'β–ˆ'.repeat(progress/5)}${'β–‘'.repeat(20-progress/5)}] ${progress}%`);
    
    // Rate limiting delay
    if (batchNumber < totalBatches) {
      await new Promise(resolve => setTimeout(resolve, 2000));
    }
  }
};

🌍 Environment Variables (Production Ready)

# .env file
EMAIL_SERVICE=gmail
[email protected]
EMAIL_PASS=your-app-password
EMAIL_DAILY_LIMIT=100
EMAIL_DELAY=2000
EMAIL_MAX_RETRIES=3
EMAIL_RATE_LIMIT_ENABLED=true
EMAIL_MAX_PER_MINUTE=10
EMAIL_MAX_PER_HOUR=100
// Use environment variables
import { createConfigFromEnv } from '@prathammahajan/multi-email-sender';

const config = createConfigFromEnv();
const sender = new EmailSender(config);

πŸ† Best Practices & Tips

πŸ’‘ Pro Tips for Success

  • βœ… Use App Passwords for Gmail/Yahoo (never regular passwords)
  • βœ… Enable 2FA on your email accounts
  • βœ… Store credentials in environment variables
  • βœ… Use dedicated email accounts for sending
  • βœ… Monitor your sending reputation regularly
  • πŸš€ Batch processing for large lists (50-100 emails per batch)
  • πŸš€ Use appropriate delays based on your provider
  • πŸš€ Monitor rate limits and adjust accordingly
  • πŸš€ Enable logging for debugging and optimization
  • πŸš€ Use templates for consistent formatting
  • πŸ“ˆ Track success rates and identify patterns
  • πŸ“ˆ Monitor error types to improve reliability
  • πŸ“ˆ Set up alerts for high failure rates
  • πŸ“ˆ Regular log analysis for optimization
  • πŸ“ˆ A/B test different sending strategies

πŸ”§ Troubleshooting Guide

❓ Common Issues & Solutions

Problem: Authentication failed or Invalid credentials

Solutions:

  1. βœ… Verify email and password are correct
  2. βœ… For Gmail: Use app passwords instead of regular passwords
  3. βœ… Enable 2-factor authentication
  4. βœ… Check if account is locked or suspended
  5. βœ… Verify SMTP settings for custom providers
// Test your configuration
const isValid = sender.validateConfiguration();
console.log('Configuration valid:', isValid);

Problem: Emails being delayed or blocked

Solutions:

  1. βœ… Reduce maxEmailsPerMinute setting
  2. βœ… Increase delayBetweenEmails
  3. βœ… Use multiple email accounts for rotation
  4. βœ… Check your provider's specific limits
  5. βœ… Monitor rate limit statistics
// Check current rate limit status
const status = sender.rateLimiter.getStatus();
console.log('Rate limit status:', status);

Problem: Timeouts or connection failures

Solutions:

  1. βœ… Increase timeout setting
  2. βœ… Check internet connection stability
  3. βœ… Verify SMTP server settings
  4. βœ… Try different ports (587 vs 465)
  5. βœ… Check firewall settings
// Increase timeout for slow networks
const sender = new EmailSender({
  email: { /* config */ },
  options: {
    timeout: 60000, // 60 seconds
    maxRetries: 5
  }
});

πŸ“š API Reference

🎯 Core Classes

| Class | Description | Key Methods | |-------|-------------|-------------| | EmailSender | Main email sending class | sendToMultiple(), sendSingle(), getStatistics() | | Logger | Comprehensive logging system | info(), error(), getLogs(), getStatistics() | | RetryLogic | Intelligent retry mechanism | executeWithRetry(), getRetryStatistics() | | RateLimiter | Smart rate limiting | waitIfNeeded(), getStatus(), updateConfig() |

πŸ”§ Configuration Options

{
  email: {
    service: 'gmail',           // 'gmail', 'outlook', 'yahoo', 'custom'
    auth: {
      user: '[email protected]',
      pass: 'password'
    },
    host: 'smtp.domain.com',    // For custom SMTP
    port: 587,                  // For custom SMTP
    secure: false               // For custom SMTP
  },
  options: {
    dailyLimit: 100,            // Max emails per day
    delayBetweenEmails: 2000,   // Delay in milliseconds
    maxRetries: 3,              // Max retry attempts
    retryDelay: 1000,           // Base retry delay
    timeout: 30000,             // Send timeout
    enableLogging: true,        // Enable detailed logging
    logFile: 'email-logs.json'  // Log file path
  },
  rateLimit: {
    enabled: true,              // Enable rate limiting
    maxEmailsPerMinute: 10,     // Max emails per minute
    maxEmailsPerHour: 100       // Max emails per hour
  }
}

🀝 Contributing & Support

πŸš€ Get Involved

We love contributions! Here's how you can help:

  1. πŸ› Report bugs - Found an issue? Let us know!
  2. πŸ’‘ Suggest features - Have ideas? We'd love to hear them!
  3. πŸ”§ Submit PRs - Fix bugs or add features
  4. πŸ“– Improve docs - Help others learn
  5. ⭐ Star the repo - Show your support!

πŸ“ž Support Channels


πŸ“„ License & Legal

This project is licensed under the MIT License - see the LICENSE file for details.

Made with ❀️ by Pratham Mahajan


🎯 Perfect For

| πŸ›’ E-commerce | πŸ“§ Marketing | πŸ”” Notifications | πŸ“Š Analytics | |-------------------|------------------|---------------------|------------------| | Order confirmations | Newsletter campaigns | System alerts | Performance tracking | | Shipping updates | Promotional emails | User notifications | Delivery insights | | Customer support | Welcome sequences | Password resets | Error monitoring |


πŸš€ Ready to Transform Your Email Operations?

npm install GitHub stars Buy me a coffee

Start sending emails like a pro in 30 seconds! ⚑