PHP code example of tomi0 / mailhog-api-testing

1. Go to this page and download the library: Download tomi0/mailhog-api-testing 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/ */

    

tomi0 / mailhog-api-testing example snippets


use Mailhog\MailhogTesting;

class ClassName {
    use MailhogTesting;
    ...
}

$this->setUpMailhogEnviroment($host, $smtpPort, $webPort, $isHttps);

// Check if message exsits (return bool)
$this->messageExistsByContent($content);
$this->messageExists($content);

// Get all messages (return EmailMessage[])
$this->getAllMessages();

// Clear inbox (return bool)
$this->clearInbox();
$this->emptyInbox();