PHP code example of captbaritone / mailcatcher-codeception-module

1. Go to this page and download the library: Download captbaritone/mailcatcher-codeception-module 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/ */

    

captbaritone / mailcatcher-codeception-module example snippets




$I->wantTo('Get a password reset email');

// Clear old emails from MailCatcher
$I->resetEmails();

// Reset password
$I->amOnPage('forgotPassword.php');
$I->fillField("input[name='email']", '[email protected]');
$I->click('Submit');
$I->see('Please check your inbox');

$I->seeInLastEmail('Please click this link to reset your password');

    // Clears all emails
    $I->resetEmails();
    

    $I->seeEmailAttachmentCount(1);
    

    $I->seeAttachmentInLastEmail('image.jpg');
    

    $I->seeInLastEmail('Thanks for signing up!');
    

    $I->seeInLastEmailTo('[email protected]', 'Thanks for signing up!');
    $I->seeInLastEmailTo('[email protected]', 'A new user has signed up!');
    

    $I->dontSeeInLastEmail('Hit me with those laser beams');
    

    $I->dontSeeInLastEmailTo('[email protected]', 'But shoot it in the right direction');
    

    $attachments = $I->grabAttachmentsFromLastEmail();
    

    $matches = $I->grabMatchesFromLastEmail('@<strong>(.*)</strong>@');
    

    $match = $I->grabFromLastEmail('@<strong>(.*)</strong>@');
    

    $urls = $I->grabUrlsFromLastEmail();
    

    $email = $I->lastMessageFrom('[email protected]');
    $I->assertNotEmpty($email['attachments']);
    

    $email = $I->grabLastEmail();
    $I->assertNotEmpty($email['attachments']);
    

    $matchs = $I->grabMatchesFromLastEmailTo('[email protected]', '@<strong>(.*)</strong>@');
    

    $match = $I->grabFromLastEmailTo('[email protected]', '@<strong>(.*)</strong>@');
    

    $match = $I->seeEmailCount(2);