New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

agouticreative/laravel-mailcatcher

A service provider for Alexandre Salome's PHP Mailcatcher SDK
4,048
Install
composer require agouticreative/laravel-mailcatcher:dev-master
PHP:>=5.6
License:MIT
Last Updated:Jun 15, 2016
Links: GitHub  ·  Packagist
Maintainer: agouticreative

laravel-mailcatcher

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

  1. install Mailcatcher.
  2. from the root of your project, run this command: composer install https://github.com/agouticreative/laravel-mailcatcher
  3. Add Agouti\LaravelMailcatcher\ServiceProvider::class to the providers array in config/app.php
  4. Add 'Mailcatcher' => Agouti\LaravelMailcatcher\Facade::class to the aliases array in config/app.php
  5. from the root of your project run this command: php artisan vendor:publish
  6. 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!

This is an alpha release

Related Packages

valorin/random

Random is a simple helper package designed to make it easy to generate a range o...

453,573 234
php
cline/variable-keys

Laravel Blueprint macros for variable primary key and morph types

25,062 0
php
cline/struct

Lean, attribute-driven Laravel data objects with explicit validation and Eloquen...

20,294 0
php
cline/toggl

Advanced feature flag management with strategies, time bombs, and groups

14,044 0
php
cline/sequencer

Sequential migration and operation orchestration for Laravel

12,978 0
php