ankitfromindia / parallel-smtp
High-performance parallel SMTP client for Laravel with connection pooling and pipelining - up to 10x faster bulk email sending
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ankitfromindia/parallel-smtp
Requires
- php: ^8.3
- laravel/framework: ^10.0|^11.0|^12.0
- react/promise: ^3.0
- react/socket: ^1.12
- swiftmailer/swiftmailer: ^6.3
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
README
High-performance parallel SMTP client for Laravel that dramatically improves bulk email sending performance through concurrent connections, connection pooling, and SMTP pipelining.
🚀 Performance Features
- Parallel Processing: Up to 10 concurrent SMTP connections
- Connection Pooling: Reuse connections for up to 100 messages each
- SMTP Pipelining: Reduced latency through command batching
- Auto Resource Management: Automatic connection cleanup and recycling
- Enterprise Ready: Optimized for high-volume email campaigns
📋 Requirements
- PHP 8.3+
- Laravel 10.0+, 11.0+, or 12.0+
- SMTP server that supports multiple connections
📦 Installation
Install via Composer:
composer require ankitfromindia/parallel-smtp
The package will auto-register with Laravel's service container.
⚙️ Configuration
Publish the configuration file:
php artisan vendor:publish --tag=parallel-smtp-config
Add SMTP settings to your .env file:
# SMTP Server Configuration PARALLEL_SMTP_HOST=smtp.example.com PARALLEL_SMTP_PORT=587 PARALLEL_SMTP_USERNAME=your_username PARALLEL_SMTP_PASSWORD=your_password PARALLEL_SMTP_ENCRYPTION=tls # Performance Settings PARALLEL_SMTP_MAX_CONNECTIONS=10 PARALLEL_SMTP_MESSAGES_PER_CONNECTION=100
🔧 Usage
Basic Usage
use AnkitFromIndia\ParallelSmtp\Http\ParallelSmtpClient; class BulkEmailService { public function sendCampaign(array $recipients) { $client = app(ParallelSmtpClient::class); $messages = []; foreach ($recipients as $recipient) { $messages[] = [ 'from' => 'campaign@example.com', 'to' => $recipient['email'], 'subject' => 'Welcome to Our Newsletter', 'body' => view('emails.welcome', $recipient)->render(), 'content_type' => 'text/html' ]; } $results = $client->sendBulk($messages); return $this->processResults($results); } private function processResults(array $results): array { $stats = ['sent' => 0, 'failed' => 0, 'errors' => []]; foreach ($results as $index => $result) { if ($result['success']) { $stats['sent']++; } else { $stats['failed']++; $stats['errors'][] = "Message {$index}: {$result['error']}"; } } return $stats; } }
Advanced Usage with CC/BCC
$messages = [ [ 'from' => 'sender@example.com', 'to' => 'primary@example.com', 'cc' => ['cc1@example.com', 'cc2@example.com'], 'bcc' => ['bcc@example.com'], 'subject' => 'Important Update', 'body' => '<h1>Update Notification</h1><p>Content here...</p>', 'content_type' => 'text/html' ] ]; $client = app(ParallelSmtpClient::class); $results = $client->sendBulk($messages);
📊 Performance Comparison
| Method | 1000 Emails | 10000 Emails |
|---|---|---|
| Sequential | ~15 minutes | ~2.5 hours |
| Parallel SMTP | ~2 minutes | ~20 minutes |
| Improvement | 7.5x faster | 7.5x faster |
🔧 Configuration Options
| Option | Default | Description |
|---|---|---|
max_connections |
10 | Maximum concurrent SMTP connections |
messages_per_connection |
100 | Messages per connection before reset |
smtp.host |
- | SMTP server hostname |
smtp.port |
587 | SMTP server port |
smtp.encryption |
tls | Encryption method (tls/ssl) |
🛡️ Error Handling
$results = $client->sendBulk($messages); foreach ($results as $index => $result) { if ($result['success']) { echo "✅ Email {$index}: Sent successfully\n"; } else { echo "❌ Email {$index}: {$result['error']}\n"; } }
📝 License
The MIT License (MIT). Please see License File for more information.