{"id":14985487,"url":"https://github.com/xammie/mailbook","last_synced_at":"2026-04-07T19:01:31.001Z","repository":{"id":46896302,"uuid":"510674158","full_name":"Xammie/mailbook","owner":"Xammie","description":"✉️ Laravel Mail Explorer","archived":false,"fork":false,"pushed_at":"2025-05-05T07:18:04.000Z","size":1842,"stargazers_count":458,"open_issues_count":2,"forks_count":20,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-05T08:25:36.894Z","etag":null,"topics":["laravel","mail","php","storybook","tailwindcss"],"latest_commit_sha":null,"homepage":"https://mailbook.dev","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/Xammie.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":"xammie","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-07-05T09:42:24.000Z","updated_at":"2025-05-05T07:13:35.000Z","dependencies_parsed_at":"2023-02-17T06:30:47.984Z","dependency_job_id":"20bb99c2-aaac-4cb4-8f3f-de78bbdb7734","html_url":"https://github.com/Xammie/mailbook","commit_stats":{"total_commits":281,"total_committers":5,"mean_commits":56.2,"dds":"0.12099644128113884","last_synced_commit":"0929e435b58e3237d412d88ba12fc412a9a87e05"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xammie%2Fmailbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xammie%2Fmailbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xammie%2Fmailbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xammie%2Fmailbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xammie","download_url":"https://codeload.github.com/Xammie/mailbook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160555,"owners_count":22024571,"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":["laravel","mail","php","storybook","tailwindcss"],"created_at":"2024-09-24T14:11:04.136Z","updated_at":"2026-04-07T19:01:30.967Z","avatar_url":"https://github.com/Xammie.png","language":"PHP","funding_links":["https://github.com/sponsors/xammie"],"categories":[],"sub_categories":[],"readme":"# Mailbook\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/xammie/mailbook.svg?style=flat-square)](https://packagist.org/packages/xammie/mailbook)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/xammie/mailbook/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/xammie/mailbook/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/xammie/mailbook/pint.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/xammie/mailbook/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/xammie/mailbook.svg?style=flat-square)](https://packagist.org/packages/xammie/mailbook)\n\nMailbook is a Laravel package that lets you easily inspect your mails without having to actually trigger it in your\napplication.\n\n[![Example screenshot](./screenshot.png)](https://mailbook.dev)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://mailbook.dev/\"\u003eView demo\u003c/a\u003e\u003c/p\u003e\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require --dev xammie/mailbook\n```\n\nNext install mailbook into your application\n\n```bash\nphp artisan mailbook:install\n```\n\n## Usage\n\nThe `mailbook:install` command will create a route file named `routes/mailbook.php`. In this file you can register your\nemails.\n\n```php\n// This will use dependency injection if your mailable has parameters\nMailbook::add(VerificationMail::class);\n\n// Use a closure to customize the parameters of the mail instance\nMailbook::add(function (): VerificationMail {\n    $user = User::factory()-\u003emake();\n\n    return new VerificationMail($user, '/example/url')\n});\n```\n\nNext head over to `/mailbook` to preview the mailables.\n\n## Registering mails\n\nYou can both register mailables that live in `App\\Mails` and email notifications in `App\\Notifications`.\n\n```php\n// Mailable\nMailbook::add(VerificationMail::class);\n\n// Notification\nMailbook::add(InvoiceCreatedNotification::class);\n```\n\nYou can also use dependency injection in the closure.\n\n```php\n// With dependency injection\nMailbook::add(function (VerificationService $verificationService): VerificationMail {\n    return new VerificationMail($verificationService, '/example/url');\n});\n\n// Without dependency injection\nMailbook::add(function (): VerificationMail {\n    $verificationService = app(VerificationService::class);\n    \n    return new VerificationMail($verificationService, '/example/url');\n});\n```\n\n## Sending to a user\n\nA notification will most of the time need a user (also called `notifiable` in the notification class).\nYou can set the desired user with the `::to()` method.\n\n```php\n$user = User::factory()-\u003ecreate();\n\nMailbook::to($user)-\u003eadd(WelcomeNotification::class);\n```\n\nIf you don't need a user you can also pass an e-mail address.\n\n```php\nMailbook::to('example@mailbook.dev')-\u003eadd(WelcomeNotification::class)\n```\n\n## Grouping multiple mails\n\nYou can group multiple mails under the same category. This can be done using the `category()` and `group()` methods.\n\n```php\nMailbook::category('Invoices')-\u003egroup(function () {\n    Mailbook::add(InvoiceCreatedNotification::class);\n    Mailbook::add(InvoicePaidNotification::class);\n});\n```\n\nTo avoid having to pass the same `to()` to every mailable that needs it you can also use the `group()` method. This will\nuse the notifiable to every mailable inside the group.\n\n```php\nMailbook::to('example@mailbook.dev')-\u003egroup(function () {\n    Mailbook::add(WelcomeNotification::class);\n    Mailbook::add(TrialEndedNotification::class);\n});\n```\n\nIt is also possible to chain both `category()` and `to()` to the same group.\n\n```php\nMailbook::to('example@mailbook.dev')\n    -\u003ecategory('Invoices')\n    -\u003egroup(function () {\n        // ...\n    });\n```\n\n## Variants\n\nWhen creating mails you might have a couple of different scenario's that you want to test for one mail, you can use\nvariants to solve this.\n\n```php\n// Use a closure to customize the parameters of the mail instance\nMailbook::add(OrderCreatedMail::class)\n    -\u003evariant('1 item', fn () =\u003e new OrderCreatedMail(Order::factory()-\u003ewithOneProduct()-\u003ecreate()))\n    -\u003evariant('2 items', fn () =\u003e new OrderCreatedMail(Order::factory()-\u003ewithTwoProducts()-\u003ecreate()));\n```\n\n## Localization\n\nWhen your application supports multiple languages you need to easily preview your mails in these languages. To enable\nthis feature you have to add the following code to the `mailbook.php` config file.\n\n```php\n'locales' =\u003e [\n    'en' =\u003e 'English',\n    'nl' =\u003e 'Dutch',\n    'de' =\u003e 'German',\n    'es' =\u003e 'Spanish'\n],\n```\n\nThis will display a dropdown in mailbook which you can use to switch to a different language.\n\n![Localization](./docs/localization.png)\n\n## Using the database\n\nMost of the time your mailables will need database models. Sometimes you will even preform queries when rendering these\nmailables. Mailbook can automatically rollback database changes after rendering. You can enable it in the config with.\n\n```php\n'database_rollback' =\u003e true,\n```\n\nYou can now safely use factories and other queries when registering your mailables.\n\n```php\n// All database changes are rolled back after rendering the mail.\nMailbook::add(function (): OrderShippedMail {\n    $order = Order::factory()-\u003ecreate();\n    $tracker = Tracker::factory()-\u003ecreate();\n        \n    return new OrderShippedMail($order, $tracker);\n});\n```\n\nDatabase rollback is disabled by default.\n\n## Sending Mails\n\nTesting your mails outside the browser is important if you want to make sure that everything is displayed correctly.\nYou can use Mailbook to send mails to an email address of your choice using your default mail driver. This will show a\nbutton in the top-right corner which when pressed will send the currently selected email to the specified address.\nYou can enable this in the config:\n\n```php\n'send' =\u003e true,\n'send_to' =\u003e 'test@mailbook.dev',\n```\n\n## Customization\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"mailbook-config\"\n```\n\nOptionally, you can publish the views using\n\n```bash\nphp artisan vendor:publish --tag=\"mailbook-views\"\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](https://github.com/Xammie/mailbook/blob/main/CHANGELOG.md) for more information on what has changed recently.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](https://github.com/Xammie/mailbook/security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Max Hoogenbosch](https://github.com/Xammie)\n- [All Contributors](https://github.com/Xammie/mailbook/contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/Xammie/mailbook/blob/main/LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxammie%2Fmailbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxammie%2Fmailbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxammie%2Fmailbook/lists"}