{"id":29139606,"url":"https://github.com/dynamik-dev/laravel-mail-preview","last_synced_at":"2026-03-08T13:39:32.267Z","repository":{"id":301555575,"uuid":"1009147383","full_name":"dynamik-dev/laravel-mail-preview","owner":"dynamik-dev","description":"A utility for viewing emails in your browser as you develop.","archived":false,"fork":false,"pushed_at":"2025-06-27T13:15:03.000Z","size":157,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-27T13:42:51.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dynamik-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"DynamikDev"}},"created_at":"2025-06-26T16:47:35.000Z","updated_at":"2025-06-27T13:34:39.000Z","dependencies_parsed_at":"2025-06-27T13:53:07.607Z","dependency_job_id":null,"html_url":"https://github.com/dynamik-dev/laravel-mail-preview","commit_stats":null,"previous_names":["dynamik-dev/laravel-mail-preview"],"tags_count":1,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/dynamik-dev/laravel-mail-preview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Flaravel-mail-preview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Flaravel-mail-preview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Flaravel-mail-preview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Flaravel-mail-preview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dynamik-dev","download_url":"https://codeload.github.com/dynamik-dev/laravel-mail-preview/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamik-dev%2Flaravel-mail-preview/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266026390,"owners_count":23866033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-30T15:37:32.054Z","updated_at":"2026-03-08T13:39:32.240Z","avatar_url":"https://github.com/dynamik-dev.png","language":"PHP","funding_links":["https://github.com/sponsors/DynamikDev","https://buymeacoffee.com/chrisarter"],"categories":[],"sub_categories":[],"readme":"![Laravel Mail Preview](./laravel-mail-preview.png)\n\n[![Tests](https://github.com/dynamik-dev/laravel-mail-preview/actions/workflows/run-tests.yml/badge.svg)](https://github.com/dynamik-dev/laravel-mail-preview/actions/workflows/run-tests.yml)\n[![PHPStan](https://img.shields.io/badge/PHPStan-level%205-brightgreen.svg)](https://phpstan.org/)\n\u003ca href=\"https://buymeacoffee.com/chrisarter\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-yellow.svg\" alt=\"BuyMeACoffee\"\u003e\n  \u003c/a\u003e\n  \nA utility for viewing emails in your browser as you develop with Laravel. This package allows you to preview your mailables without actually sending emails, making it easier to develop and test your email templates.\n\n```php\n// Make any mailable previewable\nclass WelcomeEmail extends Mailable implements Previewable\n{\n    public static function toPreview(): self\n    {\n        return new self(User::factory()-\u003emake());\n    }\n}\n```\nThen, view it instantly at 👀 `http://your-app.test/mail/welcome-email`\n\n\n## Table of Contents\n\n- [How to use](#how-to-use)\n  - [1. Make Your Mailable Previewable](#1-make-your-mailable-previewable)\n  - [2. View Your Email Preview](#2-view-your-email-preview)\n  - [3. Custom Preview Slugs](#3-custom-preview-slugs)\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [Configuration](#configuration)\n  - [Environment Variables](#environment-variables)\n- [Security](#security)\n- [Testing](#testing)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n\n\n\n**Think of it like Factories for your emails.**\n\n## How to use\n\n### 1. Make Your Mailable Previewable\n\nTo make a mailable previewable, implement the `Previewable` interface and add the `toPreview()` method:\n\n```php\nclass WelcomeEmail extends Mailable implements Previewable\n{\n    public static function toPreview(): self\n    {\n        return new self(\n            User::factory(['name' =\u003e 'Chris Arter'])-\u003emake()\n        );\n    }\n}\n```\n\n### 2. View Your Email Preview\n\nOnce you've made your mailable previewable, you can view it in your browser at:\n\n```\nhttp://your-app.test/mail/welcome-email\n```\n\nThe URL slug is automatically generated from your class name:\n- `WelcomeEmail` → `welcome-email`\n- `OrderConfirmationMail` → `order-confirmation-mail`\n- `TestMailable` → `test-mailable`\n\n\n\n### 3. Custom Preview Slugs\n\nYou can also define a custom preview slug by adding a static property to your mailable:\n\n```php\nclass WelcomeEmail extends Mailable implements Previewable\n{\n    public static string $previewSlug = 'welcome';\n    \n    // ... rest of your mailable code\n}\n```\n\nNow you can access it at: `http://your-app.test/mail/welcome`\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require dynamik-dev/laravel-mail-preview --dev\n```\n\nThe package will automatically register itself with Laravel.\n\n## Requirements\n\n- PHP 8.4+\n- Laravel 10.x, 11.x, or 12.x\n\n## Configuration\n\nPublish the configuration file:\n\n```bash\nphp artisan vendor:publish --provider=\"DynamikDev\\MailPreview\\MailPreviewServiceProvider\"\n```\n\nThis will create a `config/mail-preview.php` file with the following options:\n\n```php\nreturn [\n    // Enable or disable the mail preview\n    'enabled' =\u003e env('MAIL_PREVIEW_ENABLED', false),\n    \n    // The route prefix for the mail preview\n    'route_prefix' =\u003e env('MAIL_PREVIEW_ROUTE_PREFIX', 'mail'),\n    \n    // The path to discover mailables in\n    'discover_path' =\u003e env('MAIL_PREVIEW_DISCOVER_PATH', base_path('app')),\n];\n```\n\n### Environment Variables\n\nTo enable the mail preview, set `MAIL_PREVIEW_ENABLED` to `true` in your `.env` file.\n\nThese are the available options:\n\n```env\nMAIL_PREVIEW_ENABLED=true\nMAIL_PREVIEW_ROUTE_PREFIX=mail\nMAIL_PREVIEW_DISCOVER_PATH=/path/to/your/app\n```\n\n## Security\n\n**Important**: This package should only be enabled in development environments. The mail preview routes expose your email templates and could potentially leak sensitive information.\n\nMake sure to:\n\n1. Set `MAIL_PREVIEW_ENABLED=false` in production\n2. Add the preview routes to your middleware if needed\n3. Consider using authentication middleware for the preview routes\n\n## Testing\n\nRun the test suite:\n\n```bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Chris Arter](https://github.com/christopherarter)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamik-dev%2Flaravel-mail-preview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynamik-dev%2Flaravel-mail-preview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamik-dev%2Flaravel-mail-preview/lists"}