PHPackages                             ericmartel/codeception-email-mailhog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. ericmartel/codeception-email-mailhog

ActiveLibrary[Testing &amp; Quality](/categories/testing)

ericmartel/codeception-email-mailhog
====================================

Provides test helpers for Codeception when testing email functionality with MailHog

1.0.8(8y ago)25458.4k↑16.7%33[5 issues](https://github.com/ericmartel/codeception-email-mailhog/issues)[6 PRs](https://github.com/ericmartel/codeception-email-mailhog/pulls)9MITPHP

Since Dec 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ericmartel/codeception-email-mailhog)[ Packagist](https://packagist.org/packages/ericmartel/codeception-email-mailhog)[ RSS](/packages/ericmartel-codeception-email-mailhog/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (11)Used By (9)

MailHog Service Provider for the Codeception Email Testing Framework
====================================================================

[](#mailhog-service-provider-for-the-codeception-email-testing-framework)

This Codeception Module implements the required methods to test emails using the [Codeception Email Testing Framework](https://github.com/ericmartel/codeception-email) with [MailHog](https://github.com/mailhog/MailHog)

### Installation

[](#installation)

Through composer, require the package:

```
"require-dev": {
        "ericmartel/codeception-email-mailhog": "^1.0"
    }

```

Then turn it on in your Codeception suite yaml file

```
class_name: FunctionalTester
modules:
    enabled:
        - MailHog
    config:
        MailHog:
            url: 'http://mailhog.dev'
            port: '8025'

```

Additional parameters can be fed directly to the Guzzle connection using the `guzzleRequestOptions` variable.

The variable `deleteEmailsAfterScenario` can be set to true to ensure that all emails are deleted at the end of each scenario, but it is turned off by default.

### Added Methods

[](#added-methods)

This Module adds a few public methods for the user, such as:

```
deleteAllEmails()

```

Deletes all emails in MailHog

```
fetchEmails()

```

Fetches all email headers from MailHog, sorts them by timestamp and assigns them to the current and unread inboxes

```
accessInboxFor($address)

```

Filters emails to only keep those that are received by the provided address

```
openNextUnreadEmail()

```

Pops the most recent unread email and assigns it as the email to conduct tests on

### Example Test

[](#example-test)

Here is a simple scenario where we test the content of an email. For a detailed list of all available test methods, please refer to the [Codeception Email Testing Framework](https://github.com/ericmartel/codeception-email).

```
