rezouce / codeception-mailcatcher
Allow to use Mailcatcher with Codeception
Installs: 1 953
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- guzzlehttp/guzzle: ^6.1
- rezouce/mailcatcher: ^1.1
Requires (Dev)
This package is not auto-updated.
Last update: 2025-09-27 23:15:54 UTC
README
This is a Codeception module to test the emails send by your application, using MailCatcher.
Installation
To add it to your project run composer require rezouce/codeception-mailcatcher
You can then add MailCatcher to your Codeception configuration file in the modules enabled section:
modules: enabled: - MailCatcher
By default the module will try to contact MailCatcher on http://127.0.0.1:1080, you can change it using the configuration:
modules: enabled: - MailCatcher config: MailCatcher: url: 'http://127.0.0.1' port: '1080'
Usage
Assertions
<?php // Check if there is at least an email $this->hasEmails(); // Count the number of mails $this->seeNumberEmails(5); // Check if at least an email contains a string in its source $this->seeInEmail('A string.');
Grabbing emails
<?php $emails = $this->getEmailsBySubject('subject'); $emails = $this->getEmailsBySender('user@example.com'); $emails = $this->getEmailsByRecipients(['user1@example.com']);
By default each of these methods will retrieve emails when the property contains the search criteria. You can change to a strict check by giving a boolean as the second parameter with true as value.
It's also possible to assert on the emails you grab:
<?php $emails = $this->getEmailsBySubject('subject'); $this->hasEmails($emails);
License
This library is open-sourced software licensed under the MIT license