### Install laravel-mail package Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-mail ``` -------------------------------- ### Preview template with PreviewTemplateAction Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Preview a template with example data without sending. ```php use JeffersonGoncalves\LaravelMail\Actions\PreviewTemplateAction; $action = new PreviewTemplateAction(); $preview = $action->execute($template, ['name' => 'Alice'], 'en'); // Returns: ['subject' => '...', 'html' => '...', 'text' => '...'] // HTML is automatically CSS-inlined when templates.inline_css is true ``` -------------------------------- ### Send Test Email via CLI (mail:send-test) Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Shows bash commands for sending test emails with the mail:send-test artisan command. Includes examples with default data, a specific locale (--locale=pt_BR), and custom JSON data (--data='{"name":"Alice"}'). ```bash # Uses example data from template variables php artisan mail:send-test welcome user@example.com # With specific locale php artisan mail:send-test welcome user@example.com --locale=pt_BR # With custom JSON data php artisan mail:send-test welcome user@example.com --data='{"name":"Alice"}' ``` -------------------------------- ### Use HasMailLogs Trait for Polymorphic Mail Logs Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Adds the HasMailLogs trait to a User model, enabling queries like $user->mailLogs()->where('status', 'delivered')->latest()->get(). ```php use JeffersonGoncalves\LaravelMail\Traits\HasMailLogs; class User extends Model { use HasMailLogs; } // Query $user->mailLogs()->where('status', 'delivered')->latest()->get(); ``` -------------------------------- ### Associate mail logs with a model using HasMailLogs Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Add the HasMailLogs trait to any Eloquent model to associate mail logs with it. After adding the trait, you can retrieve the model's mail logs with $user->mailLogs()->latest()->get(). ```php use JeffersonGoncalves\LaravelMail\Traits\HasMailLogs; class User extends Model { use HasMailLogs; } $user->mailLogs()->latest()->get(); ``` -------------------------------- ### Publish and run migrations Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Publish and run the package migrations. ```bash php artisan vendor:publish --tag="laravel-mail-migrations" php artisan migrate ``` -------------------------------- ### Enable Pixel Tracking via Environment Variables Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Set these environment variables to enable open and click tracking. Both must be set to 'true' to activate the respective tracking features. ```env LARAVEL_MAIL_PIXEL_OPEN_TRACKING=true LARAVEL_MAIL_PIXEL_CLICK_TRACKING=true ``` -------------------------------- ### Publish config file Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Optionally publish the config file. ```bash php artisan vendor:publish --tag="laravel-mail-config" ``` -------------------------------- ### Preview Template with PreviewTemplateAction Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Instantiates PreviewTemplateAction and executes it with a template, data array, and locale. Returns an array with 'subject', 'html' (CSS inlined), and 'text' (null if not available). ```php use JeffersonGoncalves\LaravelMail\Actions\PreviewTemplateAction; $action = new PreviewTemplateAction(); $preview = $action->execute($template, ['name' => 'Alice'], 'en'); // Returns: ['subject' => 'rendered subject', 'html' => 'rendered html (CSS inlined)', 'text' => null] ``` -------------------------------- ### Enable Browser Preview with Environment Variable and Config Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Enable browser preview by setting the environment variable and configuring the preview array in the Laravel Mail config file. When signed_urls is true, preview URLs are cryptographically signed and cannot be tampered with; when false, plain URLs are generated. ```env LARAVEL_MAIL_PREVIEW_ENABLED=true ``` ```php // config/laravel-mail.php 'preview' => [ 'enabled' => true, 'route_prefix' => 'mail/preview', 'route_middleware' => ['web'], 'signed_urls' => true, // Require signed URLs for security ], ``` -------------------------------- ### List mail templates with mail:templates Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md List all mail templates in a table. ```bash php artisan mail:templates ``` -------------------------------- ### Configure Pixel Tracking in laravel-mail.php Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Configuration for provider-independent pixel tracking. Enable open and click tracking via environment variables, set the route prefix and middleware, and optionally provide a signing key (defaults to APP_KEY). ```php // config/laravel-mail.php 'tracking' => [ 'pixel' => [ 'open_tracking' => env('LARAVEL_MAIL_PIXEL_OPEN_TRACKING', false), 'click_tracking' => env('LARAVEL_MAIL_PIXEL_CLICK_TRACKING', false), 'route_prefix' => 'mail/t', 'route_middleware' => [], 'signing_key' => env('LARAVEL_MAIL_PIXEL_SIGNING_KEY'), // null = uses APP_KEY ], ], ``` -------------------------------- ### Update template and create version Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Update a template; a new version snapshot is automatically created. ```php $template->update([ 'subject' => ['en' => 'Updated Welcome, {{ $name }}!'], 'html_body' => ['en' => '
Welcome to our platform.
', 'pt_BR' => 'Bem-vindo a nossa plataforma.
', ], 'variables' => [ ['name' => 'name', 'type' => 'string', 'example' => 'John'], ], ]); ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Runs the test suite for the package using Composer's test script. ```bash composer test ``` -------------------------------- ### Enable multi-tenancy in laravel-mail.php Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Enable multi-tenancy by setting 'enabled' to true and specifying the tenant column name in the laravel-mail.php configuration file. ```php // config/laravel-mail.php 'tenant' => [ 'enabled' => true, 'column' => 'tenant_id', ], ``` -------------------------------- ### Query email statistics with MailStats facade Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Use the MailStats facade to query email statistics over a date range. Returns counts for sent, delivered, bounced, complained, opened, and clicked emails, plus delivery and bounce rates as percentages and a collection of daily aggregations. ```php use JeffersonGoncalves\LaravelMail\Facades\MailStats; use Illuminate\Support\Carbon; $from = Carbon::now()->subDays(30); $to = Carbon::now(); MailStats::sent($from, $to); // int MailStats::delivered($from, $to); // int MailStats::bounced($from, $to); // int MailStats::complained($from, $to); // int MailStats::opened($from, $to); // int (from tracking events) MailStats::clicked($from, $to); // int (from tracking events) MailStats::deliveryRate($from, $to); // float (percentage) MailStats::bounceRate($from, $to); // float (percentage) MailStats::dailyStats($from, $to); // Collection of daily aggregations ``` -------------------------------- ### Configure Tracking Providers in config/laravel-mail.php Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Configure tracking providers in config/laravel-mail.php. Enable the providers you use and set the required signing secrets or credentials via environment variables. ```php 'tracking' => [ 'enabled' => true, 'route_prefix' => 'webhooks/mail', 'providers' => [ 'ses' => [ 'enabled' => true, ], 'sendgrid' => [ 'enabled' => true, 'signing_secret' => env('LARAVEL_MAIL_SENDGRID_SIGNING_SECRET'), ], 'postmark' => [ 'enabled' => true, 'username' => env('LARAVEL_MAIL_POSTMARK_WEBHOOK_USERNAME'), 'password' => env('LARAVEL_MAIL_POSTMARK_WEBHOOK_PASSWORD'), ], 'mailgun' => [ 'enabled' => true, 'signing_key' => env('LARAVEL_MAIL_MAILGUN_SIGNING_KEY'), ], 'resend' => [ 'enabled' => true, 'signing_secret' => env('LARAVEL_MAIL_RESEND_SIGNING_SECRET'), ], ], ], ``` -------------------------------- ### Create TemplateMailable class Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Extend TemplateMailable to create a mailable that fetches content from the database. ```php use JeffersonGoncalves\LaravelMail\Mail\TemplateMailable; use Illuminate\Mail\Mailables\Content; class WelcomeEmail extends TemplateMailable { public function __construct( public User $user, ) {} public function templateKey(): string { return 'welcome'; } public function templateData(): array { return ['name' => $this->user->name]; } protected function fallbackSubject(): string { return 'Welcome!'; } protected function fallbackContent(): Content { return new Content( view: 'emails.welcome', with: ['user' => $this->user], ); } } ``` -------------------------------- ### Send test email with mail:send-test Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Send a test email using a template. Supports --locale and --data options for locale and custom data. ```bash # Send with example data from template variables php artisan mail:send-test welcome user@example.com # With specific locale php artisan mail:send-test welcome user@example.com --locale=pt_BR # With custom data php artisan mail:send-test welcome user@example.com --data='{"name":"Alice"}' ``` -------------------------------- ### Implement a TemplateMailable Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Create a custom Mailable class by extending TemplateMailable to integrate database templates with dynamic data and fallback views. ```php use JeffersonGoncalves\LaravelMail\Mail\TemplateMailable; use Illuminate\Mail\Mailables\Content; class OrderConfirmationEmail extends TemplateMailable { public function __construct( public Order $order, ) {} public function templateKey(): string { return 'order-confirmation'; } public function templateData(): array { return [ 'name' => $this->order->customer->name, 'order_number' => $this->order->number, ]; } protected function fallbackSubject(): string { return "Order #{$this->order->number} confirmed"; } protected function fallbackContent(): Content { return new Content(view: 'emails.order-confirmation', with: ['order' => $this->order]); } } ``` -------------------------------- ### Enable Delivery Tracking with LARAVEL_MAIL_TRACKING_ENABLED Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Enable delivery tracking via provider webhooks. Set this environment variable to true to activate tracking. ```env LARAVEL_MAIL_TRACKING_ENABLED=true ``` -------------------------------- ### Access Preview URLs via Model Accessors Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Access preview URLs via model accessors on mail log and template models. The URLs include a signature when signed_urls is enabled. ```php $mailLog->preview_url; // GET /mail/preview/mail-log/{id}?signature=... $template->preview_url; // GET /mail/preview/template/{id}?signature=... ``` -------------------------------- ### Send Notification via TemplateMailChannel Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Defines a WelcomeNotification class that uses TemplateMailChannel. The toTemplateMail method returns template_key, data, and locale. Sending is done with $user->notify(new WelcomeNotification()). ```php use JeffersonGoncalves\LaravelMail\Channels\TemplateMailChannel; use Illuminate\Notifications\Notification; class WelcomeNotification extends Notification { public function via($notifiable): array { return [TemplateMailChannel::class]; } public function toTemplateMail($notifiable): array { return [ 'template_key' => 'welcome', 'data' => ['name' => $notifiable->name], 'locale' => $notifiable->preferred_locale, ]; } } // Send it $user->notify(new WelcomeNotification()); ``` -------------------------------- ### Create a MailTemplate Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Use the MailTemplate model to create a new email template with multi-language support for subjects and body content, along with defined variables. ```php use JeffersonGoncalves\LaravelMail\Models\MailTemplate; $template = MailTemplate::create([ 'key' => 'order-confirmation', 'name' => 'Order Confirmation', 'subject' => [ 'en' => 'Order #{{ $order_number }} confirmed', 'pt_BR' => 'Pedido #{{ $order_number }} confirmado', ], 'html_body' => [ 'en' => 'Order #{{ $order_number }}
', 'pt_BR' => 'Pedido #{{ $order_number }}
', ], 'variables' => [ ['name' => 'name', 'type' => 'string', 'example' => 'John'], ['name' => 'order_number', 'type' => 'string', 'example' => '12345'], ], 'is_active' => true, ]); ``` -------------------------------- ### Listen to Tracking Events (MailBounced, MailComplained) Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Listen to tracking events such as MailBounced and MailComplained. The event objects provide access to the MailLog and MailTrackingEvent models. ```php use JeffersonGoncalves\LaravelMail\Events\MailBounced; use JeffersonGoncalves\LaravelMail\Events\MailComplained; // In a listener or EventServiceProvider Event::listen(MailBounced::class, function (MailBounced $event) { // $event->mailLog — the MailLog model // $event->trackingEvent — the MailTrackingEvent model Log::warning("Email bounced: {$event->trackingEvent->recipient}"); }); Event::listen(MailComplained::class, function (MailComplained $event) { // Disable the user's account, send alert, etc. }); ``` -------------------------------- ### Send email with automatic logging Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Send an email normally; it is automatically logged to the mail_logs table. ```php // Just send emails normally — they are logged automatically Mail::to('user@example.com')->send(new WelcomeMail($user)); ``` -------------------------------- ### View email statistics with mail:stats Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Show email statistics. By default, shows the last 7 days; use --days to specify a different period. ```bash php artisan mail:stats # Last 7 days (default) php artisan mail:stats --days=30 # Last 30 days ``` -------------------------------- ### Schedule mail:prune daily Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Schedule the mail:prune command to run daily using Laravel's scheduler. ```php Schedule::command('mail:prune')->daily(); ``` -------------------------------- ### Configure attachment file storage with LARAVEL_MAIL_STORE_ATTACHMENT_FILES Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Enable storing email attachment files to disk via environment variables or the config file. When enabled, each attachment is stored to the configured disk and the path and disk are added to the attachment metadata in the mail log. Stored files are automatically cleaned up when pruning. ```env LARAVEL_MAIL_STORE_ATTACHMENT_FILES=true LARAVEL_MAIL_ATTACHMENTS_DISK=local # or s3, etc. ``` ```php // config/laravel-mail.php 'logging' => [ 'store_attachment_files' => true, 'attachments_disk' => 'local', 'attachments_path' => 'mail-attachments', ], ``` -------------------------------- ### Use LaravelMail and MailStats facades Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Use the LaravelMail facade to check logging/tracking status, find a mail log by provider message ID, or update its status. Use the MailStats facade to retrieve mail statistics such as sent count, delivery rate, and daily stats. Both facades are imported from the JeffersonGoncalves\LaravelMail\Facades namespace. ```php use JeffersonGoncalves\LaravelMail\Facades\LaravelMail; LaravelMail::isLoggingEnabled(); // bool LaravelMail::isTrackingEnabled(); // bool LaravelMail::findByProviderMessageId('msg-id-123'); // ?MailLog LaravelMail::updateStatus($mailLog, MailStatus::Delivered); // MailLog ``` ```php use JeffersonGoncalves\LaravelMail\Facades\MailStats; MailStats::sent($from, $to); MailStats::deliveryRate($from, $to); MailStats::dailyStats($from, $to); ``` -------------------------------- ### Configure custom table names in laravel-mail.php Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Customize the database connection and table names used by the package. Set 'connection' to null for the default connection, and map each table key to the desired table name. ```php // config/laravel-mail.php 'database' => [ 'connection' => null, 'tables' => [ 'mail_logs' => 'mail_logs', 'mail_templates' => 'mail_templates', 'mail_template_versions' => 'mail_template_versions', 'mail_tracking_events' => 'mail_tracking_events', 'mail_suppressions' => 'mail_suppressions', ], ], ``` -------------------------------- ### Enable Suppression with Environment Variable and Config Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Enable the suppression feature by setting the environment variable and configuring the suppression array in the Laravel Mail config file. When enabled, hard-bounced and complained addresses are automatically added to the suppression list and blocked from receiving future emails. ```env LARAVEL_MAIL_SUPPRESSION_ENABLED=true ``` ```php // config/laravel-mail.php 'suppression' => [ 'enabled' => true, 'auto_suppress_hard_bounces' => true, 'auto_suppress_complaints' => true, ], ``` -------------------------------- ### Configure List-Unsubscribe Headers in config/laravel-mail.php Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Configure List-Unsubscribe headers for Gmail/Yahoo compliance. The {email} placeholder in the URL is replaced with the recipient's email address. ```php // config/laravel-mail.php 'templates' => [ 'unsubscribe' => [ 'enabled' => true, 'url' => 'https://yourapp.com/unsubscribe/{email}', // {email} is replaced with recipient 'mailto' => 'unsubscribe@yourapp.com', ], ], ``` -------------------------------- ### Retry failed emails via artisan mail:retry command Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Retry failed emails via the artisan command. Use --status and --hours to filter by status and time window, and --limit to cap the number of retries. Hard bounces are automatically skipped. ```bash # Retry failed emails from the last 24 hours php artisan mail:retry # Retry soft-bounced emails from the last 48 hours php artisan mail:retry --status=bounced --hours=48 # Limit the number of retries php artisan mail:retry --limit=50 ``` -------------------------------- ### Resend a logged email with ResendMailAction Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Resend any previously logged email by instantiating the ResendMailAction and calling execute with the mail log entry. ```php use JeffersonGoncalves\LaravelMail\Actions\ResendMailAction; $action = new ResendMailAction(); $action->execute($mailLog); ``` -------------------------------- ### Enable Inline CSS with LARAVEL_MAIL_INLINE_CSS Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Enable automatic inlining of CSS styles for email client compatibility. This is enabled by default. ```env LARAVEL_MAIL_INLINE_CSS=true # Enabled by default ``` -------------------------------- ### Retry Failed Email with RetryFailedMailAction Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Instantiates RetryFailedMailAction and executes it with a failed mail log. Checks retry.max_attempts, resends via ResendMailAction, and increments metadata.retry_count. ```php use JeffersonGoncalves\LaravelMail\Actions\RetryFailedMailAction; $action = new RetryFailedMailAction(); $success = $action->execute($failedMailLog); // Checks retry.max_attempts, resends via ResendMailAction, increments metadata.retry_count ``` -------------------------------- ### Manually Suppress and Check Suppression with MailSuppression Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Manually suppress an email address by creating a MailSuppression record with a reason of SuppressionReason::Manual, and check if an address is suppressed using a query on the MailSuppression model. ```php use JeffersonGoncalves\LaravelMail\Models\MailSuppression; use JeffersonGoncalves\LaravelMail\Enums\SuppressionReason; // Manually suppress an address MailSuppression::create([ 'email' => 'user@example.com', 'reason' => SuppressionReason::Manual, 'suppressed_at' => now(), ]); // Check if an address is suppressed $isSuppressed = MailSuppression::where('email', 'user@example.com')->exists(); ``` -------------------------------- ### Use translation API on MailTemplate Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Access and manage translations on the MailTemplate model. ```php // Get for current locale $template->subject; // Returns string for app()->getLocale() // Get for specific locale $template->getSubjectForLocale('pt_BR'); $template->getHtmlBodyForLocale('en'); $template->getTextBodyForLocale('es'); // Get all translations $template->getTranslations('subject'); // ['en' => '...', 'pt_BR' => '...'] // Set translation $template->setTranslation('subject', 'fr', 'Bienvenue !'); ``` -------------------------------- ### Enable retry configuration in laravel-mail.php Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Enable automatic retry of failed emails by setting 'retry.enabled' to true and configuring the maximum number of attempts. ```php // config/laravel-mail.php 'retry' => [ 'enabled' => true, 'max_attempts' => 3, ], ``` -------------------------------- ### Unsuppress an Email Address with Artisan Command Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Run the artisan command to remove a suppression for the given email address, allowing future emails to be sent to it. ```bash php artisan mail:unsuppress user@example.com ``` -------------------------------- ### Access Translations via spatie/laravel-translatable Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Retrieve or set translated content for specific locales using the MailTemplate model's translation methods. ```php // MailTemplate uses HasTranslations trait // Translatable fields: subject, html_body, text_body // Get for current locale $template->subject; // Returns string for app()->getLocale() // Get for specific locale (with fallback) $template->getSubjectForLocale('pt_BR'); $template->getHtmlBodyForLocale('en'); $template->getTextBodyForLocale('es'); // Get all translations as array $template->getTranslations('subject'); // ['en' => '...', 'pt_BR' => '...'] // Set translation for a specific locale $template->setTranslation('subject', 'fr', 'Bienvenue !'); $template->save(); ``` -------------------------------- ### Control stored email content Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Control which parts of the email are stored (HTML and/or text). ```env LARAVEL_MAIL_STORE_HTML=true LARAVEL_MAIL_STORE_TEXT=true ``` -------------------------------- ### Configure custom models in laravel-mail.php Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Override the default model classes used by the package by mapping each model key to your own Eloquent model class in the laravel-mail.php configuration file. ```php // config/laravel-mail.php 'models' => [ 'mail_log' => \App\Models\MailLog::class, 'mail_template' => \App\Models\MailTemplate::class, 'mail_template_version' => \App\Models\MailTemplateVersion::class, 'mail_tracking_event' => \App\Models\MailTrackingEvent::class, 'mail_suppression' => \App\Models\MailSuppression::class, ], ``` -------------------------------- ### Prune old mail logs with mail:prune Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Clean up old mail logs using the mail:prune command. Without options, logs older than 30 days are pruned; use --days to specify a different age. ```bash php artisan mail:prune # Prune logs older than 30 days (default) php artisan mail:prune --days=7 # Prune logs older than 7 days ``` -------------------------------- ### Listen to MailBounced Event Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/resources/boost/skills/laravel-mail-development/SKILL.md Listen to the MailBounced event to handle bounce notifications. The event provides a MailLog record and a MailTrackingEvent with bounce_type and recipient. Available events include MailDelivered, MailBounced, MailComplained, MailOpened, MailClicked, and MailDeferred. ```php use JeffersonGoncalves\LaravelMail\Events\MailBounced; use JeffersonGoncalves\LaravelMail\Events\MailDelivered; // In EventServiceProvider or listener Event::listen(MailBounced::class, function (MailBounced $event) { // $event->mailLog — the MailLog record // $event->trackingEvent — the MailTrackingEvent with bounce_type, recipient, etc. $recipient = $event->trackingEvent->recipient; $bounceType = $event->trackingEvent->bounce_type; Log::warning("Bounce ({$bounceType}): {$recipient}"); }); ``` -------------------------------- ### Send database templates via Laravel Notifications Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Define a Laravel notification that sends a database template via TemplateMailChannel. The toTemplateMail method returns the template key, data array, and locale. ```php use JeffersonGoncalves\LaravelMail\Channels\TemplateMailChannel; use Illuminate\Notifications\Notification; class WelcomeNotification extends Notification { public function via($notifiable): array { return [TemplateMailChannel::class]; } public function toTemplateMail($notifiable): array { return [ 'template_key' => 'welcome', 'data' => ['name' => $notifiable->name], 'locale' => 'en', ]; } } ``` -------------------------------- ### Disable logging with LARAVEL_MAIL_LOGGING_ENABLED Source: https://github.com/jeffersongoncalves/laravel-mail/blob/master/README.md Disable email logging by setting this environment variable to false. ```env LARAVEL_MAIL_LOGGING_ENABLED=false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.