PHP code example of johnatannvmd / codeception-mailchecker-module

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

    

johnatannvmd / codeception-mailchecker-module example snippets



    $I = new WebGuy($scenario);
    $I->wantTo('Get a password reset email');

    // Cleared old emails from MailCatcher
    $I->clearMailbox();

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

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

## Actions

### clearMailbox

Clears the emails in providers's list. This is prevents seeing emails sent
during a previous test. You probably want to do this before you trigger any
emails to be sent

Example:

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

    $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');
    

    $I->seeAttachmentFilenameInLastEmail('expected_journey.ext');
    

    $I->dontSeeAttachmentFilenameInLastEmail('unexpected_journey.ext');
    

    $I->seeAttachmentFilenameInLastEmailTo('[email protected]', 'expected_journey.ext');
    

    $I->dontSeeAttachmentFilenameInLastEmailTo('[email protected]', 'unexpected_journey.ext');
    

    $I->seeAttachmentsCountInLastEmail(1);
    

    $I->seeAttachmentsCountInLastEmailTo('[email protected]', 1);
    

    $I->seeCcInLastEmail('[email protected]');
    

    $I->seeCcInLastEmailTo('[email protected]', '[email protected]');
    

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

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

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

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

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