PHPackages                             ericmartel/codeception-email-mailtrap - 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. ericmartel/codeception-email-mailtrap

ActiveLibrary

ericmartel/codeception-email-mailtrap
=====================================

Provides test helpers for Codeception when testing email functionality with Mailtrap

1.0.5(9y ago)015.5k↓100%5[2 issues](https://github.com/ericmartel/codeception-email-mailtrap/issues)[1 PRs](https://github.com/ericmartel/codeception-email-mailtrap/pulls)MITPHP

Since Jan 4Pushed 7y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (2)Versions (7)Used By (0)

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

[](#mailtrap-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 [Mailtrap](http://mailtrap.io)

### Installation

[](#installation)

Through composer, require the package:

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

```

Then turn it on in your Codeception suite yaml file

```
class_name: FunctionalTester
modules:
    enabled:
        - Mailtrap
    config:
        Mailtrap:
            api_token: 'your token'
            inbox_id: 'the inbox id you're using'

```

The `api_token` can be found by visiting your Mailtrap's [API Page](https://mailtrap.io/public_api). Clicking on one of your mailboxes will give you it's id in the URL, for example, `https://mailtrap.io/inboxes/12345/settings` would mean that the `inbox_id` is `12345`.

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 Mailtrap

```
fetchEmails()

```

Fetches all email headers from Mailtrap, 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).

```
