PHP code example of kirschbaum-development / mail-intercept

1. Go to this page and download the library: Download kirschbaum-development/mail-intercept library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kirschbaum-development / mail-intercept example snippets


namespace Tests;

use App\Mail\TestMail;
use Illuminate\Support\Facades\Mail;
use Illuminate\Foundation\Testing\WithFaker;
use KirschbaumDevelopment\MailIntercept\WithMailInterceptor;

class MailTest extends TestCase
{
    use WithFaker;
    use WithMailInterceptor;

    public function testMail()
    {
        $this->interceptMail();

        $email = $this->faker->email;

        Mail::to($email)->send(new TestMail());

        $interceptedMail = $this->interceptedMail()->first();

        $interceptedMail->assertSentTo($email);
    }
}

$interceptedMail->assertSentTo($email);

$this->assertMailSentTo($email, $interceptedEmail);

$this->interceptMail()

$this->interceptedMail()