PHP code example of dynamik-dev / laravel-mail-preview

1. Go to this page and download the library: Download dynamik-dev/laravel-mail-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/ */

    

dynamik-dev / laravel-mail-preview example snippets


// Make any mailable previewable
class WelcomeEmail extends Mailable implements Previewable
{
    public static function toPreview(): self
    {
        return new self(User::factory()->make());
    }
}

class WelcomeEmail extends Mailable implements Previewable
{
    public static function toPreview(): self
    {
        return new self(
            User::factory(['name' => 'Chris Arter'])->make()
        );
    }
}

class WelcomeEmail extends Mailable implements Previewable
{
    public static string $previewSlug = 'welcome';
    
    // ... rest of your mailable code
}

return [
    // Enable or disable the mail preview
    'enabled' => env('MAIL_PREVIEW_ENABLED', false),
    
    // The route prefix for the mail preview
    'route_prefix' => env('MAIL_PREVIEW_ROUTE_PREFIX', 'mail'),
    
    // The path to discover mailables in
    'discover_path' => env('MAIL_PREVIEW_DISCOVER_PATH', base_path('app')),
];
bash
php artisan vendor:publish --provider="DynamikDev\MailPreview\MailPreviewServiceProvider"