PHPackages                             zdenekgebauer/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. zdenekgebauer/codeception-email-mailhog

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

zdenekgebauer/codeception-email-mailhog
=======================================

Provides test helpers for Codeception when testing email functionality with MailHog

028PHPCI failing

Since Dec 14Pushed 5mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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": {
    "oqq/codeception-email-mailhog": "^2.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

```
grabHeadersFromEmail()

```

Grabs headers from the opened email and returns them as an array

### 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).

```
