fullstack/inbounder
Composer 安装命令:
composer require fullstack/inbounder
包简介
A comprehensive Laravel package for Mailgun integration with email templates, distribution lists, webhook handling, and queue management.
README 文档
README
A comprehensive Laravel package for Mailgun integration with email templates, distribution lists, webhook handling, and queue management.
Features
- Email Templates: Create and manage reusable email templates with variable substitution
- Distribution Lists: Manage email distribution lists with subscriber management
- Webhook Processing: Handle Mailgun webhooks for tracking and analytics
- Inbound Email: Process incoming emails with attachment support
- Queue Management: Dedicated queue configuration for email processing
- Authorization: Flexible authorization system (Gates, Policies, Spatie Permissions)
- Event System: Comprehensive event system for all operations
- Console Commands: CLI tools for managing templates and distribution lists
Installation
composer require fullstack/inbounder
Configuration
Basic Configuration
Publish the configuration file:
php artisan vendor:publish --tag=inbounder-config
Configure your Mailgun credentials in .env:
MAILGUN_DOMAIN=your-domain.com MAILGUN_SECRET=your-api-key MAILGUN_WEBHOOK_SIGNING_KEY=your-webhook-signing-key MAIL_FROM_ADDRESS=noreply@your-domain.com MAIL_FROM_NAME=Your App Name
Queue Configuration
The package supports custom queue configuration for better performance and isolation:
# Enable custom queue configuration MAILGUN_QUEUE_ENABLED=true # Default queue name MAILGUN_QUEUE_NAME=mailgun # Specific queue names for different job types MAILGUN_QUEUE_TEMPLATED_EMAILS=mailgun-emails MAILGUN_QUEUE_WEBHOOKS=mailgun-webhooks MAILGUN_QUEUE_INBOUND=mailgun-inbound MAILGUN_QUEUE_TRACKING=mailgun-tracking # Queue connection (default, redis, sqs, etc.) MAILGUN_QUEUE_CONNECTION=redis # Retry configuration MAILGUN_QUEUE_MAX_ATTEMPTS=3 MAILGUN_QUEUE_RETRY_DELAY=60 MAILGUN_QUEUE_BACKOFF=true # Timeout configuration MAILGUN_QUEUE_JOB_TIMEOUT=300 MAILGUN_QUEUE_TIMEOUT=600 # Batch processing MAILGUN_QUEUE_BATCH_ENABLED=true MAILGUN_QUEUE_BATCH_SIZE=100 MAILGUN_QUEUE_BATCH_DELAY=5
Queue Workers
Set up queue workers for the Mailgun queues:
# Process templated emails php artisan queue:work --queue=mailgun-emails # Process webhook events php artisan queue:work --queue=mailgun-webhooks # Process inbound emails php artisan queue:work --queue=mailgun-inbound # Process tracking events php artisan queue:work --queue=mailgun-tracking
Or use supervisor to manage multiple workers:
[program:mailgun-emails] command=php /path/to/your/app/artisan queue:work --queue=mailgun-emails --sleep=3 --tries=3 autostart=true autorestart=true user=www-data numprocs=2 redirect_stderr=true stdout_logfile=/path/to/your/app/storage/logs/mailgun-emails.log
Usage
Email Templates
Create an email template:
use Inbounder\Models\EmailTemplate; $template = EmailTemplate::create([ 'name' => 'Welcome Email', 'slug' => 'welcome-email', 'subject' => 'Welcome to {{company}}!', 'html_content' => '<h1>Welcome {{name}}!</h1><p>Thank you for joining {{company}}.</p>', 'text_content' => 'Welcome {{name}}! Thank you for joining {{company}}.', 'variables' => ['name', 'company'], 'is_active' => true, ]);
Send a templated email:
use Inbounder\Services\TemplatedEmailJobDispatcher; $dispatcher = app(TemplatedEmailJobDispatcher::class); // Send to one recipient $dispatcher->sendToOne( 'user@example.com', 'welcome-email', ['name' => 'John Doe', 'company' => 'Acme Corp'] ); // Send to multiple recipients $recipients = [ ['email' => 'user1@example.com', 'name' => 'John', 'company' => 'Acme'], ['email' => 'user2@example.com', 'name' => 'Jane', 'company' => 'Acme'], ]; $dispatcher->sendToMany($recipients, 'welcome-email'); // Send as a batch $batch = $dispatcher->sendBatch($recipients, 'welcome-email');
Distribution Lists
Create a distribution list:
use Inbounder\Models\DistributionList; $list = DistributionList::create([ 'name' => 'Newsletter Subscribers', 'slug' => 'newsletter-subscribers', 'description' => 'Monthly newsletter subscribers', 'category' => 'newsletter', 'is_active' => true, ]);
Add subscribers:
use Inbounder\Services\DistributionListService; $service = app(DistributionListService::class); $service->addSubscribers($list->id, [ ['email' => 'user1@example.com', 'name' => 'John Doe'], ['email' => 'user2@example.com', 'name' => 'Jane Smith'], ]);
Send to distribution list:
$service->sendCampaign($list->id, 'newsletter-template', [ 'month' => 'January', 'year' => '2024', ]);
Webhook Handling
Set up webhook routes in your routes/web.php:
Route::post('/mailgun/webhook', [MailgunController::class, 'webhook']) ->middleware('verify.mailgun.webhook'); Route::post('/mailgun/inbound', [MailgunController::class, 'inbound']) ->middleware('verify.mailgun.webhook');
Authorization
Configure authorization in your config/inbounder.php:
'authorization' => [ 'method' => 'gate', // 'gate', 'policy', or 'spatie' 'gate_name' => 'send-email', 'policy_method' => 'sendEmail', 'spatie_permission' => 'send email', ],
Define your authorization logic:
// Using Gates Gate::define('send-email', function ($user) { return $user->hasPermission('send-email'); }); // Using Policies class UserPolicy { public function sendEmail(User $user): bool { return $user->hasPermission('send-email'); } } // Using Spatie Permissions $user->givePermissionTo('send email');
Events
Listen to package events:
use Inbounder\Events\EmailTemplateCreated; use Inbounder\Events\DistributionListCreated; Event::listen(EmailTemplateCreated::class, function ($event) { Log::info('Email template created', [ 'template_id' => $event->getTemplateId(), 'template_name' => $event->getTemplateName(), ]); }); Event::listen(DistributionListCreated::class, function ($event) { Log::info('Distribution list created', [ 'list_id' => $event->getListId(), 'list_name' => $event->getListName(), ]); });
Console Commands
Email Templates
# Create a template php artisan inbounder:templates:create # List templates php artisan inbounder:templates:list # Send a templated email php artisan inbounder:templates:send
Distribution Lists
# Create a distribution list php artisan inbounder:lists:create # List distribution lists php artisan inbounder:lists:list # Add subscribers php artisan inbounder:lists:add-subscribers # Remove subscribers php artisan inbounder:lists:remove-subscribers # Send campaign php artisan inbounder:lists:send-campaign
Testing
Run the test suite:
composer test
The package includes comprehensive tests with high coverage for all components.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
This package is open-sourced software licensed under the MIT license.
fullstack/inbounder 适用场景与选型建议
fullstack/inbounder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mail」 「queue」 「email」 「templates」 「laravel」 「mailgun」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fullstack/inbounder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fullstack/inbounder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fullstack/inbounder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP AMQP Binding Library
A Laravel package to monitor queue jobs.
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
Mail libraries used by Zimbra Api
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-28