mailjet/mailjet-apiv3-php
Official Mailjet PHP wrapper for the Mailjet API v3. Send and track transactional emails, manage contacts, lists and templates, handle events, and integrate Mailjet features in PHP apps with simple client setup and HTTP calls.
Pros:
mailable classes + queue:work). The package abstracts HTTP calls, enabling seamless integration with Laravel’s event system (e.g., sent, failed hooks).Client, Resources\Email, Resources\Contact) mirrors Laravel’s Eloquent/Service Container patterns, reducing boilerplate for API interactions.config, env, and facades (e.g., Mailjet::send()). Can be extended via Laravel’s service providers for dependency injection.Cons:
spatie/laravel-mail.Mail facade (e.g., Mail::to()->send(new MailjetMailable)), unlike dedicated Laravel mail drivers.illuminate/http.config/mailjet.php with env() variables (e.g., MAILJET_API_KEY, MAILJET_API_SECRET).Cache::remember) for API keys or contact lists.Mockery or PestPHP for unit/feature tests (e.g., Mailjet::shouldReceive('send')->once()).Mailjet\Exception\MailjetException), but Laravel’s try/catch or App\Exceptions\Handler can standardize responses (e.g., logging, user notifications).throttle middleware or queue batching..env (never in code). Use Laravel’s Vault (if available) or laravel/env-editor for rotation.failed_jobs table) suffice, or is a custom retry logic layer needed?laravel/activitylog or custom auditing be required?laravel-notification-channels or a custom event listener?config differentiate between them (e.g., mailjet.template_id)?Laravel Core:
Mail facade for hybrid workflows (e.g., Mail::to($user)->send(new MailjetMailable)).Mailjet\Client to Laravel’s container in AppServiceProvider:
$this->app->singleton(Mailjet\Client::class, function ($app) {
return new Mailjet\Client(
$app['config']['mailjet.api_key'],
$app['config']['mailjet.api_secret']
);
});
Illuminate\Mail\Events\MessageSent to trigger Mailjet-specific actions (e.g., analytics).Queue System:
MailjetMailable classes with ->onQueue('mailjet') and configure a mailjet queue in config/queue.php.ShouldQueue interface for async sends:
class MailjetMailable extends Mailable implements ShouldQueue {
public function build() {
return $this->to($this->recipient)
->subject('Test')
->with([...]);
}
}
Webhooks:
routes/web.php:
Route::post('/mailjet/webhook', [MailjetWebhookController::class, 'handle']);
spatie/laravel-webhook-server to validate signatures and dispatch Laravel events.Phase 1: Core Integration (1-2 weeks)
PHPMailer/SwiftMailer with the package for transactional emails.config/mail.php to use the package as a fallback:
'mailers' => [
'mailjet' => [
'transport' => 'mailjet',
],
],
Resources\Email).Phase 2: Async & Scaling (1 week)
ShouldQueue.throttle:60,1 for API calls).Phase 3: Advanced Features (1-2 weeks)
message_sent, bounce events).mailjet_events table for webhook payloads.composer require mailjet/mailjet-apiv3-php.php artisan vendor:publish --provider="Mailjet\ServiceProvider" (if available)..env variables:
MAILJET_API_KEY=your_key
MAILJET_API_SECRET=your_secret
config/mailjet.php (or extend Laravel’s config/mail.php).Mailjet\Client interactions.ngrok.composer why-not mailjet/mailjet-apiv3-php).App\Exceptions\Handler:
reportable(function (Mailjet\Exception\MailjetException $e) {
Log::error('Mailjet API error', ['exception' => $e]);
});
log mailer or a secondary providerHow can I help you explore Laravel packages today?