Skip to content

[13.x] Fake html() and plain() on MailFake - #62162

Merged
taylorotwell merged 2 commits into
laravel:13.xfrom
xurshudyan:mail-fake-html-plain
Oct 24, 2026
Merged

taylorotwell merged 2 commits into
laravel:13.xfrom
xurshudyan:mail-fake-html-plain

Conversation

@xurshudyan

Copy link
Copy Markdown
Contributor

Mail::fake() stubs Mail::raw(), but Mail::html() and Mail::plain() are forwarded to the real mailer, so they send real emails during tests:

Mail::fake();

Mail::html('<p>Hello</p>', fn ($message) => $message->to('taylor@laravel.com'));

Mail::assertNothingOutgoing(); // passes, but the email was sent

This adds both methods to the fake.

@xurshudyan
xurshudyan force-pushed the mail-fake-html-plain branch from 8a85560 to ef37850 Compare October 23, 2026 12:27
* Send a new message with only an HTML part.
*
* @param string $html
* @param \Closure|string $callback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a type here:

Suggested change
* @param \Closure|string $callback
* @param (\Closure(\Illuminate\Mail\Message): void)|string $callback

@taylorotwell
taylorotwell merged commit a62d615 into laravel:13.x Oct 24, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants