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

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

janhelke/codeception-email-mailhog
==================================

Provides test helpers for Codeception when testing email functionality with MailHog

2.0.1(2y ago)074.4k↓11.6%1MITPHP

Since Aug 7Pushed 2y agoCompare

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

READMEChangelog (3)Dependencies (2)Versions (4)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": {
        "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).

```
