PHPackages                             fetch/zend-mail-codeception-module - 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. fetch/zend-mail-codeception-module

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

fetch/zend-mail-codeception-module
==================================

Test emails in your Codeception acceptance tests

v1.0.0(10y ago)124PHP

Since Nov 27Pushed 10y ago2 watchersCompare

[ Source](https://github.com/fetch/zend-mail-codeception-module)[ Packagist](https://packagist.org/packages/fetch/zend-mail-codeception-module)[ RSS](/packages/fetch-zend-mail-codeception-module/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (3)Used By (0)

Zend Mail Codeception Module
============================

[](#zend-mail-codeception-module)

[![Build Status](https://camo.githubusercontent.com/ade379966086c20a709237c0a1df2bd06f67aecea5f1ce7238192f05ac2e3943/68747470733a2f2f7472617669732d63692e6f72672f66657463682f7a656e642d6d61696c2d636f646563657074696f6e2d6d6f64756c652e737667)](https://travis-ci.org/fetch/zend-mail-codeception-module)

This module will let you test emails that are sent during your Codeception acceptance tests.

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

[](#installation)

Add the package into your composer.json:

```
{
    "require-dev": {
        "codeception/codeception": "*",
        "fetch/zend-mail-codeception-module": "^1.0"
    }
}

```

Tell Composer to download the package:

```
php composer.phar update

```

Update your Zend mail configuration to use a file transport:

```
function mail_filename(){
  return uniqid() . '.mail';
}

$transportOptions = new Zend\Mail\Transport\FileOptions([
  'path' => 'tests/_output/mail',
  'callback' => 'mail_filename'
]);
$transport = new Zend\Mail\Transport\File($transportOptions);
```

Then enable it in your `acceptance.suite.yml` configuration and set path to the transport directory.

```
class_name: WebGuy
modules:
  enabled:
    - ZendMail
  config:
    ZendMail:
      path: 'tests/_output/mail'
```

You will then need to rebuild your actor class:

```
php codecept.phar build

```

Example Usage
-------------

[](#example-usage)

```
$I = new WebGuy($scenario);
$I->wantTo('Get a password reset email');

// Cleared old emails from path
$I->resetEmails();

// Reset
$I->amOnPage('forgotPassword.php');
$I->fillField("input[name='email']", 'user@example.com');
$I->click("Submit");
$I->see("Please check your email");

$I->seeInLastEmail("Please click this link to reset your password");
```

Actions
-------

[](#actions)

### resetEmails

[](#resetemails)

Clears the emails in the messages directory. This is prevents seeing emails sent during a previous test. You probably want to do this before you trigger any emails to be sent

Example:

```
// Clears all emails
$I->resetEmails();
```

### seeInLastEmail

[](#seeinlastemail)

Checks that an email contains a value. It searches the full raw text of the email: headers, subject line, and body.

Example:

```
$I->seeInLastEmail('Thanks for signing up!');
```

- Param $text

### seeInLastEmailTo

[](#seeinlastemailto)

Checks that the last email sent to an address contains a value. It searches the full raw text of the email: headers, subject line, and body.

This is useful if, for example a page triggers both an email to the new user, and to the administrator.

Example:

```
$I->seeInLastEmailTo('user@example.com', 'Thanks for signing up!');
$I->seeInLastEmailTo('admin@example.com', 'A new user has signed up!');
```

- Param $email
- Param $text

### dontSeeInLastEmail

[](#dontseeinlastemail)

Checks that an email does NOT contain a value. It searches the full raw text of the email: headers, subject line, and body.

Example:

```
$I->dontSeeInLastEmail('Hit me with those laser beams');
```

- Param $text

### dontSeeInLastEmailTo

[](#dontseeinlastemailto)

Checks that the last email sent to an address does NOT contain a value. It searches the full raw text of the email: headers, subject line, and body.

Example:

```
$I->dontSeeInLastEmailTo('admin@example.com', 'But shoot it in the right direction');
```

- Param $email
- Param $text

### grabMatchesFromLastEmail

[](#grabmatchesfromlastemail)

Extracts an array of matches and sub-matches from the last email based on a regular expression. It searches the full raw text of the email: headers, subject line, and body. The return value is an array like that returned by `preg_match()`.

Example:

```
$matches = $I->grabMatchesFromLastEmail('@(.*)@');
```

- Param $regex

### grabFromLastEmail

[](#grabfromlastemail)

Extracts a string from the last email based on a regular expression. It searches the full raw text of the email: headers, subject line, and body.

Example:

```
$match = $I->grabFromLastEmail('@(.*)@');
```

- Param $regex

### grabMatchesFromLastEmailTo

[](#grabmatchesfromlastemailto)

Extracts an array of matches and sub-matches from the last email to a given address based on a regular expression. It searches the full raw text of the email: headers, subject line, and body. The return value is an array like that returned by `preg_match()`.

Example:

```
$matchs = $I->grabMatchesFromLastEmailTo('user@example.com', '@(.*)@');
```

- Param $email
- Param $regex

### grabFromLastEmailTo

[](#grabfromlastemailto)

Extracts a string from the last email to a given address based on a regular expression. It searches the full raw text of the email: headers, subject line, and body.

Example:

```
$match = $I->grabFromLastEmailTo('user@example.com', '@(.*)@');
```

- Param $email
- Param $regex

### seeEmailCount

[](#seeemailcount)

Asserts that a certain number of emails have been sent since the last time `resetEmails()` was called.

Example:

```
$match = $I->seeEmailCount(2);
```

- Param $count

License
=======

[](#license)

Released under the same license as Codeception: MIT

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 74.5% 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

Unknown

Total

1

Last Release

3868d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e2f7409882eecce482c2a111163b24a02777e688ad2d495e6a6b965f47a92252?d=identicon)[koenpunt](/maintainers/koenpunt)

---

Top Contributors

[![captbaritone](https://avatars.githubusercontent.com/u/162735?v=4)](https://github.com/captbaritone "captbaritone (38 commits)")[![AntoineAugusti](https://avatars.githubusercontent.com/u/295709?v=4)](https://github.com/AntoineAugusti "AntoineAugusti (4 commits)")[![koenpunt](https://avatars.githubusercontent.com/u/351038?v=4)](https://github.com/koenpunt "koenpunt (3 commits)")[![falk](https://avatars.githubusercontent.com/u/30613?v=4)](https://github.com/falk "falk (2 commits)")[![rgeraads](https://avatars.githubusercontent.com/u/6044164?v=4)](https://github.com/rgeraads "rgeraads (1 commits)")[![andersonamuller](https://avatars.githubusercontent.com/u/1681800?v=4)](https://github.com/andersonamuller "andersonamuller (1 commits)")[![mobileka](https://avatars.githubusercontent.com/u/1132388?v=4)](https://github.com/mobileka "mobileka (1 commits)")[![akireikin](https://avatars.githubusercontent.com/u/2033719?v=4)](https://github.com/akireikin "akireikin (1 commits)")

### Embed Badge

![Health badge](/badges/fetch-zend-mail-codeception-module/health.svg)

```
[![Health](https://phpackages.com/badges/fetch-zend-mail-codeception-module/health.svg)](https://phpackages.com/packages/fetch-zend-mail-codeception-module)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M359](/packages/dms-phpunit-arraysubset-asserts)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

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