PHPackages                             rpkamp/mailhog-mink-behat-context - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. rpkamp/mailhog-mink-behat-context

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

rpkamp/mailhog-mink-behat-context
=================================

Mailhog Extension for Behat

1.1.1(10mo ago)358.2k↑28.6%2MITPHPPHP ^7.4 || ^8.0CI failing

Since Dec 17Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/rpkamp/mailhog-mink-behat-context)[ Packagist](https://packagist.org/packages/rpkamp/mailhog-mink-behat-context)[ RSS](/packages/rpkamp-mailhog-mink-behat-context/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (14)Versions (11)Used By (0)

Mailhog Mink Behat Context [![Packagist Version](https://camo.githubusercontent.com/9c91f3d89b3d4918d944a6da29ab780e6cd61f10d8156d6f8b8bec95d3de7d63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72706b616d702f6d61696c686f672d6d696e6b2d62656861742d636f6e74657874)](https://camo.githubusercontent.com/9c91f3d89b3d4918d944a6da29ab780e6cd61f10d8156d6f8b8bec95d3de7d63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72706b616d702f6d61696c686f672d6d696e6b2d62656861742d636f6e74657874)
=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#mailhog-mink-behat-context-)

A PHP (7.4+) [Behat](http://behat.org/) context for [Mailhog](https://github.com/mailhog/MailHog) with [Mink](http://mink.behat.org/en/latest/) integration.

Allows to simulate link clicks in emails and continue from the links URL in Mink. Suitable in browser-email-browser flows such as forgotten password resets.

This context is based on the `MailhogAwareContext` from [rpkamp/mailhog-behat-extension](https://github.com/rpkamp/mailhog-behat-extension).

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

[](#installation)

This package does not require any specific HTTP client implementation, but it requires [rpkamp/mailhog-client](https://github.com/rpkamp/mailhog-client), which is based on [HTTPlug](https://github.com/php-http/httplug), so you can inject your own HTTP client of choice. So you when you install this extension make sure you either already have an HTTP client installed, or install one at the same time as installing this context, otherwise installation will fail.

```
composer require rpkamp/mailhog-mink-behat-context
```

For more information please refer to the [HTTPlug documentation for Library Users](http://docs.php-http.org/en/latest/httplug/users.html).

Usage
-----

[](#usage)

### Register extension in Behat

[](#register-extension-in-behat)

This context require `rpkamp/mailhog-behat-extension` to be enabled in your behat configuration.

If you have not already done so, add the MailhogExtension extension to your `behat.yml` like so:

```
default:
  suites:
    # your suite configuration here
  extensions:
    rpkamp\Behat\MailhogExtension:
      base_url: http://localhost:8025
```

The `base_url` is the URL where the Mailhog Web UI is listening to (by default this is `http://localhost:8025`).

And also include the `\rpkamp\Behat\MailhogExtension\Context\MinkAwareMailogContext` in your contexts for behat:

```
default:
  suites:
    contexts:
      - rpkamp\Behat\Context\MinkAwareMailhogContext
```

Note that this context does *not* extend `rpkamp\Behat\MailhogExtension\Context\MailhogContext` from [rpkamp/mailhog-behat-extension](https://github.com/rpkamp/mailhog-behat-extension), so if you need functionality from both contexts you need to include both contexts in your behat configuration.

Gherkin steps
-------------

[](#gherkin-steps)

This context contains the following gherkin steps:

```
When I click the link "link-description" in the last received email
When I click the link "link-description" in the opened email
```

This first step will fetch the last received email from Mailhog and search for a link with "link-description" as (in order):

- id attribute *(&lt;a id="link-description"&gt;&lt;/a&gt;)*
- link text *(&lt;a&gt;link-description&lt;/a&gt;)*
- title attribute *(&lt;a title="link-description"&gt;&lt;/a&gt;)*
- alt attribute *(&lt;a alt="link-description"&gt;&lt;/a&gt;)*
- partial link text *(&lt;a&gt;some link-description&lt;/a&gt;)*

It will stop when it finds any of the above criteria fits and that tell Mink to follow that link, so from there on you can continue in Mink. This enables scenarios like password reset where you receive an email, click a link in that email and then do something in a browser.

The second step fetches the email that was opened using [rpkamp/mailhog-behat-extension](mailhog-behat-extension) and open the link with "link-description" in that, using the same procedure as outline above.

Run tests
---------

[](#run-tests)

Make sure you have Mailhog running and run:

```
make test
```

### Running Mailhog for tests

[](#running-mailhog-for-tests)

You can either run your own instance of Mailhog or use the provided docker-compose file to run one for you. To run Mailhog with Docker make sure you have Docker and docker-compose installed and run:

```
docker-compose up -d
```

### Mailhog ports for tests

[](#mailhog-ports-for-tests)

To prevent port collisions with any other Mailhog instances while testing the tests expect Mailhog to listen to SMTP on port 4025 (instead of the default 1025) and to HTTP traffic on port 11025 (instead of the default 8025).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance54

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 96.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~312 days

Recently: every ~536 days

Total

10

Last Release

311d ago

Major Versions

0.4.1 → 1.0.02020-12-29

PHP version history (4 changes)0.1.0PHP ^7.1

0.3.0PHP ^7.2

0.4.1PHP ^7.2 || ^8.0

1.1.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/79a3929a9bceef3d45d7e4987b268ee6f1a15220959b0724ec66d2a46e0009e3?d=identicon)[rpkamp](/maintainers/rpkamp)

---

Top Contributors

[![rpkamp](https://avatars.githubusercontent.com/u/1059790?v=4)](https://github.com/rpkamp "rpkamp (74 commits)")[![amanpilgrim](https://avatars.githubusercontent.com/u/10766500?v=4)](https://github.com/amanpilgrim "amanpilgrim (2 commits)")[![Devristo](https://avatars.githubusercontent.com/u/1564257?v=4)](https://github.com/Devristo "Devristo (1 commits)")

---

Tags

behatbehat-contextmailhogminkphp

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rpkamp-mailhog-mink-behat-context/health.svg)

```
[![Health](https://phpackages.com/badges/rpkamp-mailhog-mink-behat-context/health.svg)](https://phpackages.com/packages/rpkamp-mailhog-mink-behat-context)
```

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

22215.7M173](/packages/drupal-drupal-extension)[symfony/browser-kit

Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically

3.0k295.2M3.3k](/packages/symfony-browser-kit)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[spatie/crawler

Crawl all internal links found on a website

2.8k18.5M67](/packages/spatie-crawler)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[silverstripe/framework

The SilverStripe framework

7313.7M2.8k](/packages/silverstripe-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
