PHPackages                             koehnlein/codeception-email-mailpit - 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. koehnlein/codeception-email-mailpit

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

koehnlein/codeception-email-mailpit
===================================

Provides test helpers for Codeception when testing email functionality with Mailpit

v0.3.3(10mo ago)6168.7k↓17.5%2MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Sep 17Pushed 10mo ago1 watchersCompare

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

READMEChangelog (5)Dependencies (6)Versions (13)Used By (2)

Mailpit Module for the Codeception Testing Framework
====================================================

[](#mailpit-module-for-the-codeception-testing-framework)

This codeception module can be used to run tests against your [Mailpit](https://github.com/axllent/mailpit) instance.

Mailpit was inspired by MailHog, which is not developed anymore. Because it is not a 1:1 replacement, the API changed and existing MailHog codeception modules cannot be used anymore.

This codeception module is based on [oqq/codeception-email-mailhog](https://github.com/oqq/codeception-email-mailhog)(wich is a fork of [ericmartel/codeception-email-mailhog](https://github.com/ericmartel/codeception-email-mailhog)) and brings nearly the same functionality for Mailpit as the mentioned modules did for MailHog.

Installation
------------

[](#installation)

Through composer, require the package:

```
composer req koehnlein/codeception-email-mailpit --dev
```

Then turn it on in your Codeception suite yaml file

```
class_name: FunctionalTester
modules:
    enabled:
        - Mailpit
    config:
        Mailpit:
            url: 'http://mailpit.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 Mailpit

```
fetchEmails()
```

Fetches all email headers from Mialpit, 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

```
openNextAttachmentInOpenedEmail()
```

Pops the next attachment and assigns it as the attachment 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\]\[CodeceptionEmailTestingFramework\].

```
