Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laracoft's avatar
Level 27

How to assert an email was sent?

public function test_can_send_email()
{
    Mail::fake();

    Mail::send([], [], function (\Illuminate\Mail\Message $message) {
        return $message
            ->from('[email protected]')
            ->to('[email protected]')
            ->subject('test');
    });

    Mail::assertSentCount(1);
    Mail::assertQueuedCount(1);
}

Both my assertions keep failing, how should I assert instead?

0 likes
3 replies
laracoft's avatar
Level 27

@Tray2 sorry I don't follow, the article uses mailables, I'm not.

laracoft's avatar
laracoft
OP
Best Answer
Level 27

In the end, I used mailables

Please or to participate in this conversation.