1. Go to this page and download the library: Download xammie/mailbook 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/ */
xammie / mailbook example snippets
// This will use dependency injection if your mailable has parameters
Mailbook::add(VerificationMail::class);
// Use a closure to customize the parameters of the mail instance
Mailbook::add(function (): VerificationMail {
$user = User::factory()->make();
return new VerificationMail($user, '/example/url')
});
// Use a closure to customize the parameters of the mail instance
Mailbook::add(OrderCreatedMail::class)
->variant('1 item', fn () => new OrderCreatedMail(Order::factory()->withOneProduct()->create()))
->variant('2 items', fn () => new OrderCreatedMail(Order::factory()->withTwoProducts()->create()));
// All database changes are rolled back after rendering the mail.
Mailbook::add(function (): OrderShippedMail {
$order = Order::factory()->create();
$tracker = Tracker::factory()->create();
return new OrderShippedMail($order, $tracker);
});