PHPackages                             deegitalbe/laravel-mail-assertions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. deegitalbe/laravel-mail-assertions

ActiveLibrary[Testing &amp; Quality](/categories/testing)

deegitalbe/laravel-mail-assertions
==================================

PHPUnit mail assertions for testing email in Laravel.

2.0.0(3y ago)02.0kMITPHPPHP ^8.0

Since Feb 3Pushed 3y agoCompare

[ Source](https://github.com/deegitalbe/laravel-mail-assertions)[ Packagist](https://packagist.org/packages/deegitalbe/laravel-mail-assertions)[ RSS](/packages/deegitalbe-laravel-mail-assertions/feed)WikiDiscussions develop Synced 2d ago

READMEChangelog (1)Dependencies (9)Versions (23)Used By (0)

SPINEN's Laravel Mail Assertions
================================

[](#spinens-laravel-mail-assertions)

NOTE: This is based off a video titled ["Testing Email With Custom Assertions"](https://laracasts.com/series/phpunit-testing-in-laravel/episodes/12) that [Jeffrey Way](https://github.com/JeffreyWay) did on [Laracasts.com](https://laracasts.com). If you do not have an account on that site, then you should make one. It is an amazing resource. We have just taken that example &amp; made it an easy-to-install package. Thanks Jeffrey!

[![Latest Stable Version](https://camo.githubusercontent.com/95b1d02db8b0b8a7fb8a04fc609dd116ac301fc24316c61f4da480e68edf593b/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f762f737461626c65)](https://packagist.org/packages/spinen/laravel-mail-assertions)[![Latest Unstable Version](https://camo.githubusercontent.com/cb39698163d0fcee9d0c05ba7816932ae0455fee7b089100d652cf41438b8d7e/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f762f756e737461626c65)](https://packagist.org/packages/spinen/laravel-mail-assertions#dev-master)[![Total Downloads](https://camo.githubusercontent.com/46ac9fc4954f1da0f78fccd69b2ed024d38d4a6183b3d34acc4e337fd888949d/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f646f776e6c6f616473)](https://packagist.org/packages/spinen/laravel-mail-assertions)[![License](https://camo.githubusercontent.com/487fc2230c115f122c0e838f472c01e85ddf1def54ea5ea85e19f707b8db19d9/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f6c6963656e7365)](https://packagist.org/packages/spinen/laravel-mail-assertions)

PHPUnit mail assertions for testing email in Laravel.

Build Status
------------

[](#build-status)

BranchStatusCoverageCode QualityDevelop[![Build Status](https://github.com/spinen/laravel-mail-assertions/workflows/CI/badge.svg?branch=develop)](https://github.com/spinen/laravel-mail-assertions/workflows/CI/badge.svg?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/9d560a1250b963d47ae35621dd72edc72a67fa937fbdbabbd929eb7a485d1120/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-mail-assertions/?branch=develop)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6eec9fa755f475cc44288e143572adc79fa3e7376ce63c3f4e5698837c5d1a84/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-mail-assertions/?branch=develop)Master[![Build Status](https://github.com/spinen/laravel-mail-assertions/workflows/CI/badge.svg?branch=master)](https://github.com/spinen/laravel-mail-assertions/workflows/CI/badge.svg?branch=master)[![Code Coverage](https://camo.githubusercontent.com/141929cca98089f219360b420193ca97474d1d894c1bc086e715bd33e85aa7c9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-mail-assertions/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/895a5db1fef4b34b13eb9c32c93c56866f6c778b7eb2edb452a91336dafcbc82/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d6d61696c2d617373657274696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-mail-assertions/?branch=master)Installation
------------

[](#installation)

Install the package inside your dev dependencies:

```
$ composer require spinen/laravel-mail-assertions --dev
```

Configuration
-------------

[](#configuration)

In order for the package to be able to make assertions on your emails, it has to be able to "read" the messages. It does so by parsing the Laravel log, so your mail driver has to be "log" for this package to function.

Usage
-----

[](#usage)

You mixin the assertions with the `Spinen\MailAssertions\MailTracking` trait. You get the following assertions...

- seeEmailBcc
- seeEmailCc
- seeEmailContains
- seeEmailContentTypeEquals
- seeEmailCountEquals
- seeEmailDoesNotContain
- seeEmailEquals
- seeEmailFrom
- seeEmailPriorityEquals
- seeEmailReplyTo
- seeEmailSubjectContains
- seeEmailSubjectDoesNotContain
- seeEmailSubjectEquals
- seeEmailTo
- seeEmailWasNotSent
- seeEmailWasSent

NOTE: If there was more than 1 email sent, then the assertions look at the last email.

Example
-------

[](#example)

```
