Skip to content

Tomi0/mailhog-api-testing

Repository files navigation

Mailhog Api Testing

Test that your emails are sent

Install

composer require tomi0/mailhog-api-testing

Usage

Use Mailhog testing trait in your test:

use Mailhog\MailhogTesting;

class ClassName {
    use MailhogTesting;
    ...
}

Set up environment:

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

Available methods:

// 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();