mrclln/mass-mailer

A powerful Laravel package for mass email campaigns with customizable UI frameworks (Bootstrap/Tailwind), auto-detection features, and automatic file upload from CSV for cross-platform compatibility

Installs: 41

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/mrclln/mass-mailer

2.2.2 2025-11-26 01:58 UTC

This package is auto-updated.

Last update: 2025-11-26 01:59:58 UTC


README

A comprehensive Laravel package for mass email campaigns with advanced logging, analytics, and Livewire components. Features a clean interface that works with both Bootstrap and Tailwind CSS frameworks.

โœจ Features

Core Email Functionality

  • ๐ŸŽฏ Smart Personalization - Use variables like {{ first_name }}, {{ email }} for personalized content
  • ๐Ÿ“Š CSV Import - Upload recipient lists with automatic data mapping
  • ๐Ÿ“Ž Flexible Attachments - Global attachments for all recipients or individual ones per person
  • โœจ Rich Text Editor - Compose emails with formatting using Quill.js
  • ๐Ÿ‘ฅ Multiple Senders - Switch between different email accounts/senders
  • ๐Ÿ‘€ Email Preview - See exactly how your email will look before sending
  • โšก Background Processing - Queue-based sending for better performance
  • ๐Ÿ”’ SMTP Validation - Test email credentials before saving sender profiles
  • ๐ŸŽจ Dual Framework Support - Choose between Bootstrap 5 or Tailwind CSS
  • ๐Ÿ“ฑ Fully Responsive - Works perfectly on all devices
  • ๐Ÿ” Secure & Configurable - File validation, rate limiting, and customizable settings

Advanced Logging & Analytics (v2.0.0)

  • ๐Ÿ“ˆ MassMailerLogs Component - Comprehensive log management interface
  • ๐Ÿ” Advanced Filtering - Search by recipient, subject, error messages, status, and date ranges
  • ๐Ÿ“Š Dashboard Statistics - Real-time metrics and success rate tracking
  • ๐Ÿ“ค Export Functionality - CSV and JSON export with filtered data support
  • ๐Ÿ”„ Retry Mechanism - Retry failed emails directly from the interface
  • ๐Ÿ‘๏ธ Log Details View - Comprehensive view of individual email logs
  • ๐Ÿ—‘๏ธ Data Management - Clear old logs with confirmation dialogs
  • ๐Ÿ“‹ Pagination - Efficient browsing of large log datasets

User Analytics & Integration (v2.0.0)

  • ๐Ÿ‘ค MassMailerUserTrait - Comprehensive trait for User model integration
  • ๐Ÿ“Š 30+ Analytics Methods - Email analytics and reporting for users
  • โฐ Time-based Analytics - Daily, weekly, monthly, and yearly reporting
  • ๐Ÿ“ˆ Performance Tracking - Success rates, failure analysis, recipient tracking
  • ๐Ÿ’พ Data Export - CSV and array export capabilities for user email logs
  • ๐Ÿ”— Relationship Methods - Direct relationships for logs and senders
  • ๐ŸŽฏ Advanced Reporting - Performance trends, subject performance analysis
  • ๐Ÿ”’ User Data Isolation - Built-in security for multi-user environments

๐Ÿ—๏ธ Service Architecture (v2.1.0)

  • ๐Ÿ”ง Clean Code Structure - Refactored with dedicated service classes for better maintainability
  • ๐Ÿ“ฆ Service-Based Design - Separate services for attachments, CSV processing, senders, recipients, and email templates
  • ๐Ÿงช Enhanced Testability - Dependency injection and service container usage for better testing
  • โšก Improved Performance - Optimized code structure with reduced file size
  • ๐Ÿ”„ Better Maintainability - Changes localized to specific services

๐Ÿš€ Modern File Upload (v2.2.0)

  • ๐Ÿ’ซ FilePond Integration - Modern, drag-and-drop file upload interface
  • ๐ŸŽจ Visual File Management - Beautiful file upload with image previews and progress indicators
  • ๐Ÿ“ Drag & Drop Support - Users can drag files directly onto upload areas
  • ๐Ÿ–ผ๏ธ Image Preview - Automatic preview for uploaded image files
  • ๐Ÿ“Š Upload Progress - Real-time progress indicators during file uploads
  • โœ… File Type Validation - Built-in file type and size validation
  • ๐Ÿ”„ Multiple File Selection - Easy management of multiple files
  • โšก Livewire Compatible - Seamless integration with existing Livewire file handling

๐Ÿ“ Project Structure

laravel-mass-mailer/
โ”œโ”€โ”€ src/                          # Main package source code
โ”‚   โ”œโ”€โ”€ Services/                 # Service architecture (v2.1.0)
โ”‚   โ”‚   โ”œโ”€โ”€ AttachmentService.php # File attachment handling
โ”‚   โ”‚   โ”œโ”€โ”€ CsvService.php        # CSV parsing and processing
โ”‚   โ”‚   โ”œโ”€โ”€ SenderService.php     # Sender management & validation
โ”‚   โ”‚   โ”œโ”€โ”€ RecipientService.php  # Recipient management
โ”‚   โ”‚   โ””โ”€โ”€ EmailTemplateService.php # Email template processing
โ”‚   โ”œโ”€โ”€ Livewire/                 # Livewire components
โ”‚   โ”œโ”€โ”€ Views/                    # Blade templates
โ”‚   โ”œโ”€โ”€ Models/                   # Eloquent models
โ”‚   โ”œโ”€โ”€ Jobs/                     # Queue jobs
โ”‚   โ”œโ”€โ”€ Config/                   # Configuration files
โ”‚   โ””โ”€โ”€ Traits/                   # User integration traits
โ”œโ”€โ”€ docs/                         # Documentation and examples
โ”‚   โ”œโ”€โ”€ examples/                 # Test and example scripts
โ”‚   โ””โ”€โ”€ assets/                   # Images and test data
โ”œโ”€โ”€ tests/                        # PHPUnit test suite
โ””โ”€โ”€ composer.json                 # Package dependencies

๐Ÿ“ธ Screenshots

Bootstrap Version

Bootstrap Interface

Tailwind Version

Tailwind Interface

Mass Mailer Logs Interface (v2.0.0)

Mass Mailer Logs Interface

๐Ÿš€ Quick Start

composer require mrclln/mass-mailer

Basic Setup

  1. Install the package
composer require mrclln/mass-mailer
  1. Publish configuration (optional, for customization)
php artisan vendor:publish --provider="Mrclln\MassMailer\Providers\MassMailerServiceProvider" --tag="mass-mailer-config"
  1. Database Setup (recommended, for logging and analytics)
php artisan vendor:publish --provider="Mrclln\MassMailer\Providers\MassMailerServiceProvider" --tag="mass-mailer-migrations"
php artisan migrate

What this enables:

  • Complete email logging and tracking
  • User analytics and statistics
  • Advanced filtering and search capabilities
  • Export functionality for email logs
  • Retry mechanism for failed emails
  • Performance monitoring and reporting If the provider is not automatically added, open: bootstrap/providers.php and add:
return [
    // Other providers...
    Mrclln\MassMailer\Providers\MassMailerServiceProvider::class,
];
  1. Choose your UI style in .env
MASS_MAILER_UI_FRAMEWORK=bootstrap  # or 'tailwind'

๐ŸŽฏ How to Use

Add to any Blade view:

@livewire('mass-mailer')

Or use the component syntax:

<livewire:mass-mailer />

MassMailerLogs Component (v2.0.0)

View and manage all your email campaigns with the comprehensive logs interface:

@livewire('mass-mailer-logs')

Features:

  • Real-time Dashboard - View statistics, success rates, and performance metrics
  • Advanced Search & Filtering - Filter by recipient, subject, status, date ranges
  • Export Capabilities - Download logs as CSV or JSON files
  • Detailed Log View - Click any log to see full email details
  • Retry Failed Emails - Directly retry failed emails from the interface
  • Data Management - Clear old logs with confirmation dialogs
  • Responsive Design - Works on all devices with mobile-first approach

MassMailerUserTrait (v2.0.0)

Add comprehensive email analytics to your User model:

// app/Models/User.php
use Mrclln\MassMailer\Traits\MassMailerUserTrait;

class User extends Authenticatable
{
    use MassMailerUserTrait;

    // Your existing User code...
}

Available Methods:

  • Statistics: getMassMailerStats(), getMassMailerSuccessRate()
  • Time Analytics: getMassMailerEmailsSentToday(), getMassMailerEmailsSentThisWeek()
  • Performance: getMassMailerSuccessRate(), getMassMailerFailedEmails()
  • Relationships: massMailerLogs(), massMailerSenders(), successfulMassMailerLogs()
  • Export: exportMassMailerLogsToCsv(), exportMassMailerLogsToArray()
  • Analysis: getMassMailerFailureAnalysis(), getMassMailerRecipientTracking()

Example Usage:

$user = auth()->user();

// Get user's email statistics
$stats = $user->getMassMailerStats();

// Get success rate
$successRate = $user->getMassMailerSuccessRate();

// Export user's email logs
$csvData = $user->exportMassMailerLogsToCsv();

๐ŸŽจ UI Framework Support

The package automatically adapts to your chosen framework:

Bootstrap 5

  • Clean, professional interface
  • Bootstrap components and styling
  • Perfect for existing Bootstrap projects

Tailwind CSS

  • Modern utility-first design
  • Consistent with Tailwind projects
  • Highly customizable

Both versions have identical functionality and features.

โš™๏ธ Key Features Explained

Personalization with Variables

Create custom variables and drag them into your emails:

  • {{ first_name }} - Recipient's first name
  • {{ email }} - Their email address
  • Any custom variables you create

CSV Import

Upload recipient data easily:

email,first_name,last_name,company
john@example.com,John,Doe,Acme Corp
jane@example.com,Jane,Smith,Tech Inc

Multiple Senders

Configure different email accounts and even attach senders to user models for dynamic sender management:

Option 1: Configuration-based Senders

// In config/mass-mailer.php
'multiple_senders' => true,
'senders' => [
    ['name' => 'Support', 'email' => 'support@company.com'],
    ['name' => 'Sales', 'email' => 'sales@company.com'],
]

Option 2: Database-driven Senders (Recommended)

First, run the migration to create the senders table:

php artisan migrate

New in v2.0.0: SMTP Validation When adding new sender profiles, the system automatically:

  • Tests SMTP credentials before saving
  • Sends a test email to validate the configuration
  • Prevents saving invalid SMTP settings
  • Provides clear error messages for failed validations

Then create the relationship in your User model:

// app/Models/User.php
use Mrclln\MassMailer\Models\MassMailerSender;

class User extends Authenticatable
{
    // ... other code

    public function massMailerSenders()
    {
        return $this->hasMany(MassMailerSender::class);
    }
}

Configure the package to use the User model:

// config/mass-mailer.php
'multiple_senders' => true,
'sender_model' => \App\Models\User::class,

Benefits of User Model Attachment:

  • Each user can have their own sender profiles
  • Perfect for multi-tenant applications
  • Dynamic sender loading based on authenticated user
  • Easy to manage sender permissions per user
  • Supports complex business logic for sender selection
  • New senders can be added through the UI interface

Attachments

  • Global: Same file for all recipients
  • Per-recipient: Individual files for each person
  • Supports PDF, DOC, images, and more

๐Ÿ”ง Configuration Options

Customize in config/mass-mailer.php:

  • Queue Settings: Background processing configuration
  • Batch Size: Emails per batch (default: 50)
  • Rate Limiting: Max emails per minute
  • File Uploads: Size limits and allowed file types
  • UI Framework: Bootstrap or Tailwind
  • Multiple Senders: Enable sender switching

โšก Queue Worker (Important!)

Since the mass mailer uses Laravel's queue system for background processing, you must start the queue worker for emails to be sent:

php artisan queue:work --queue=mass-mailer

For production, consider using a process manager like Supervisor:

# Install Supervisor (Ubuntu/Debian)
sudo apt-get install supervisor

# Create configuration file
sudo nano /etc/supervisor/conf.d/mass-mailer-worker.conf

Add this configuration:

[program:mass-mailer-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /path/to/your/project/artisan queue:work --queue=mass-mailer --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/path/to/your/project/storage/logs/worker.log
stopwaitsecs=3600

Then start the worker:

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start mass-mailer-worker:*

๐Ÿงช Testing (v2.1.0)

The package includes comprehensive test files to verify functionality:

# Test basic functionality
php docs/examples/test-mass-mailer-trait.php

# Test email logging
php docs/examples/test-email-logging.php

# Test sender validation
php docs/examples/test-sender-validation.php

# Test CC functionality
php docs/examples/test-cc-functionality.php

# Test attachment detection
php docs/examples/test-attachment-detection.php

These test files help verify that all features work correctly in your environment.

๐Ÿ“‹ Requirements

  • PHP 8.1+
  • Laravel 10.0, 11.0, or 12.0
  • Livewire 3.0+
  • Database (recommended, for logging and analytics)

๐Ÿ“š Documentation

๐Ÿงช Examples

Example scripts and test files are available in docs/examples/:

  • test-mass-mailer-trait.php - User trait testing
  • test-email-logging.php - Email logging functionality
  • test-sender-validation.php - SMTP validation testing
  • test-cc-functionality.php - Carbon copy feature testing
  • test-attachment-detection.php - Attachment handling tests
  • test-auto-file-upload.php - File upload automation tests

๐Ÿš€ What's New in v2.2.0

  • ๐Ÿ’ซ FilePond Integration - Modern, professional file upload interface with drag-and-drop
  • ๐ŸŽจ Enhanced User Experience - Beautiful visual feedback with progress indicators and image previews
  • ๐Ÿ“ Drag & Drop Support - Users can easily drag files onto upload areas
  • ๐Ÿ–ผ๏ธ Image Preview Support - Automatic thumbnail generation for image files
  • โšก Real-time Progress - Live upload progress indicators for better user feedback
  • ๐Ÿ”„ Multiple File Management - Easy selection and management of multiple files
  • โœ… Smart Validation - Built-in file type and size validation with visual feedback
  • ๐Ÿ“ฑ Mobile Friendly - Optimized for mobile devices with touch-friendly interactions
  • ๐Ÿ”— Livewire Compatible - Seamless integration with existing Livewire functionality

๐Ÿš€ What's New in v2.1.0

  • ๐Ÿ—๏ธ Service Architecture Refactoring - Complete code restructuring with 5 dedicated service classes
  • ๐Ÿ“ฆ 53% Code Reduction - MassMailer.php reduced from 1,491 to 699 lines
  • ๐Ÿ”ง Enhanced Maintainability - Clean separation of concerns with service-based design
  • ๐Ÿงช Improved Testability - Dependency injection and service container usage
  • โšก Better Performance - Optimized code structure and reduced complexity
  • ๐Ÿ“š Professional Structure - Organized directory with docs/, examples/, and assets/ folders

๐Ÿš€ What's New in v2.0.0

  • Complete Analytics Suite - 30+ methods for user email analytics
  • Advanced Log Management - Comprehensive logging with search, filter, and export
  • SMTP Validation - Automatic testing of email credentials before saving
  • User Data Isolation - Multi-user support with proper data separation
  • Enhanced UI - Improved interfaces for both Bootstrap and Tailwind
  • Retry Mechanism - Easy retry of failed emails from the logs interface
  • Performance Monitoring - Real-time statistics and success rate tracking

Built by an individual developer sharing open source projects. This package helps make mass emailing simple and effective!