PHP code example of ejunker / mailthief

1. Go to this page and download the library: Download ejunker/mailthief 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/ */

    

ejunker / mailthief example snippets


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('[email protected]');
        $m->bcc('[email protected]');
        $m->getHeaders()->addTextHeader('X-MailThief-Variables', 'mailthief');
    });

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

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' => '[email protected]',
            'password' => 'secret',
        ]);

        // Check that an email was sent to this email address
        $this->seeMessageFor('[email protected]');

        // BCC addresses are e 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'));
    }
}