agouticreative / laravel-mailcatcher
A service provider for Alexandre Salome's PHP Mailcatcher SDK
Installs: 1 870
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- alexandresalome/mailcatcher: ~1.1
- jenssegers/model: ~1.1
This package is not auto-updated.
Last update: 2024-11-23 18:43:56 UTC
README
A Laravel service provider that returns the data on a Mailcatcher instance as an Eloquent collection of models.
Most of the heavy lifting is done by Mailcatcher SDK for PHP
Installation
- install Mailcatcher.
- from the root of your project, run this command:
composer install https://github.com/agouticreative/laravel-mailcatcher
- Add
Agouti\LaravelMailcatcher\ServiceProvider::class
to theproviders
array in config/app.php - Add
'Mailcatcher' => Agouti\LaravelMailcatcher\Facade::class
to thealiases
array in config/app.php - from the root of your project run this command:
php artisan vendor:publish
- If your Mailcatcher instance is reached at a port and location combination different from http://localhost:1080/ then change the url propery in config/mailcatcher.php to reflect the correct location
Usage
Use Mailcatcher::search()
to search the Mailcatcher instance for messages. Search takes an array of filtering arguments in the manner of the aforementioned Mailcatcher PHP SDK. Refer to that repo's instructions to learn more. A simple Mailcatcher::search()
will return all messages on Mailcatcher.
The messages' models will have these attributes:
- id (integer)
- sender (array with name and email keys)
- recipients (array of arrays with name and email keys)
- subject (string)
- content (string)
- url (a URL for viewing the content of the message, like http://localhost:1080/messages/1.html. This is particuarly useful for PHPUnit or Selenium testing.)
Attachments are not yet supported.
The original message object from the SDK is available as the messageObject property on the message model ($collection[0]->messageObject, for example)
Both the model and the collection have a delete method that will delete messages on Mailcatcher. delete on the collection completely clears out mailcatcher! be careful!