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

ActiveLibrary

svenlie/codeception-email-mailhog
=================================

Provides test helpers for Codeception when testing email functionality with MailHog

1.1.2(1y ago)12.5k—3.2%MITPHP

Since Dec 18Pushed 1y agoCompare

[ Source](https://github.com/SvenLie/codeception-email-mailhog)[ Packagist](https://packagist.org/packages/svenlie/codeception-email-mailhog)[ RSS](/packages/svenlie-codeception-email-mailhog/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (2)Versions (33)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).

```
