PHP code example of ghijk / laravel-email-preview

1. Go to this page and download the library: Download ghijk/laravel-email-preview library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ghijk / laravel-email-preview example snippets


protected function schedule(Schedule $schedule)
{
    $schedule->command('email-preview:cleanup')->daily();
}

'routes' => [
    'middleware' => ['auth', 'admin'], // Your custom middleware
],

use Ghijk\EmailPreview\Models\CapturedEmail;

// Query captured emails
$emails = CapturedEmail::query()
    ->search('[email protected]')
    ->mailableClass('App\\Mail\\WelcomeMail')
    ->dateRange('2024-01-01', '2024-12-31')
    ->get();

// Access email data
$email->to; // Array of recipients
$email->subject;
$email->html_body;
$email->text_body;
$email->attachments; // Array of attachment data
$email->mailable_class; // Original mailable class name
bash
php artisan vendor:publish --tag=email-preview-migrations
php artisan migrate
bash
# Clean up emails older than 7 days (default)
php artisan email-preview:cleanup

# Custom retention period
php artisan email-preview:cleanup --days=30
bash
php artisan vendor:publish --tag=email-preview-config