2017 © Pedro PelĂĄez
 

library mailthief

A fake Mailer for Laravel applications that takes the pain out of testing mail.

image

tightenco/mailthief

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  • Monday, February 12, 2018
  • by mattstauffer
  • Repository
  • 26 Watchers
  • 630 Stars
  • 206,730 Installations
  • PHP
  • 10 Dependents
  • 0 Suggesters
  • 47 Forks
  • 1 Open issues
  • 23 Versions
  • 10 % Grown

The README.md

Github Actions Status MailThief Logo, (*1)

MailThief

MailThief is a fake mailer for Laravel applications (5.0+) that makes it easy to test mail without actually sending any emails., (*2)

Note:

Due to changes in the way mail testing is handled by Laravel; MailThief is not needed for recent versions of the framework. MailThief will remain compatible with Laravel up to version 5.5., (*3)

Quickstart

Installation:, (*4)

composer require tightenco/mailthief --dev

Example route:, (*5)

Route::post('register', function () {
    // <snip> Validation, create account, etc. </snip>

    Mail::send('emails.welcome', [], function ($m) {
        $email = request('email');
        $m->to($email);
        $m->subject('Welcome to my app!');
        $m->from('noreply@example.com');
        $m->bcc('notifications@example.com');
        $m->getHeaders()->addTextHeader('X-MailThief-Variables', 'mailthief');
    });

    // <snip> Return response </snip>
});

If you're copying this sample test, remember to create an email view at resources/views/emails/welcome.blade.php., (*6)

Example test:, (*7)

use MailThief\Testing\InteractsWithMail;

class RegistrationTest extends TestCase
{
    // Provides convenient testing traits and initializes MailThief
    use InteractsWithMail;

    public function test_new_users_are_sent_a_welcome_email()
    {
        $this->post('register', [
            'name' => 'John Doe',
            'email' => 'john@example.com',
            'password' => 'secret',
        ]);

        // Check that an email was sent to this email address
        $this->seeMessageFor('john@example.com');

        // BCC addresses are included too
        $this->seeMessageFor('notifications@example.com');

        // Make sure the email has the correct subject
        $this->seeMessageWithSubject('Welcome to my app!');

        // Make sure the email was sent from the correct address
        $this->seeMessageFrom('noreply@example.com');

        // Make sure a given header is set on an email
        $this->seeHeaders('X-MailThief-Variables');

        // Make sure the header is set to a given value
        $this->seeHeaders('X-MailThief-Variables', 'mailthief');

        // Make sure the email contains text in the body of the message
        // Default is to search the html rendered view
        $this->assertTrue($this->lastMessage()->contains('Some text in the message'));
        // To search in the raw text
        $this->assertTrue($this->lastMessage()->contains('Some text in the message', 'raw'));
    }
}

MailThief supports just about everything you can do with the regular Laravel Mailer and Message classes. More detailed documentation is coming soon, but in the mean time, explore the MailThief and Message classes to get an idea of what's available., (*8)

If you’re using the new Mailables syntax in Laravel 5.3, you can use the native mail assertions. But if you’re using the classic mail syntax in any version of Laravel, MailThief is still your best option., (*9)

The Versions

12/02 2018

dev-master

9999999-dev

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

10/02 2018

v0.3.14

0.3.14.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

09/11 2017

v0.3.13

0.3.13.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

15/10 2017

V0.3.12

0.3.12.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

13/10 2017

v0.3.11

0.3.11.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

11/09 2017

v0.3.10

0.3.10.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

06/09 2017

v0.3.9

0.3.9.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

01/09 2017

v0.3.8

0.3.8.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

01/08 2017

v0.3.7

0.3.7.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

16/05 2017

v0.3.6

0.3.6.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

22/04 2017

v0.3.5

0.3.5.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

30/01 2017

v0.3.4

0.3.4.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

30/11 2016

v0.3.3

0.3.3.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

18/11 2016

dev-fix-see-message-from-global-from-support

dev-fix-see-message-from-global-from-support

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

13/10 2016

v0.3.2

0.3.2.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

13/09 2016

v0.3.1

0.3.1.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

08/09 2016

v0.3.0

0.3.0.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

03/08 2016

v0.2.3

0.2.3.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

29/07 2016

v0.2.2

0.2.2.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

19/07 2016

v0.2.1

0.2.1.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

14/07 2016

v0.2.0

0.2.0.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

01/07 2016

v0.1.1

0.1.1.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan

20/06 2016

v0.1.0

0.1.0.0

A fake Mailer for Laravel applications that takes the pain out of testing mail.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adam Wathan