libresign / mailpit-client
Mailpit API Client for PHP - Modern replacement for Mailhog
Installs: 169
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 16
pkg:composer/libresign/mailpit-client
Requires
- php: ^8.2
- ext-iconv: *
- ext-json: *
- php-http/httplug: ^2.0
- psr/http-factory: ^1.0
- psr/http-message: ^2.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2026-02-03 19:14:52 UTC
README
A simple PHP (8.2+) client for Mailpit, the modern replacement for Mailhog.
Design Goals
- As little dependencies as possible (PHP-HTTP compliant via HTTPlug)
- Simple single client for Mailpit API
- Integration tests on all endpoints, both happy path and failure paths
Installation
This package does not require any specific HTTP client implementation, but is based on HTTPlug, so you can inject your own HTTP client of choice. So you when you install this library make sure you either already have an HTTP client installed, or install one at the same time as installing this library, otherwise installation will fail.
composer require libresign/mailpit-client <your-http-client-of-choice>
For more information please refer to the HTTPlug documentation for Library Users.
Usage
<?php use LibreSign\Mailpit\MailpitClient; $client = new MailpitClient(new SomeHttpClient(), new SomeRequestFactory(), 'http://my.mailpit.host:port/');
Where SomeHttpClient is a class that implements Http\Client\HttpClient from HTTPlug and SomeRequestFactory is a class that implements Http\Message\RequestFactory from HTTPlug, and my.mailpit.host is the hostname (or IP) where Mailpit is running, and port is the port where the Mailpit API is running (by default 1025).
Run tests
Make sure you have Mailpit running and run:
composer cs:check composer phpmd composer phpstan composer test:coverage composer test:integration composer test:unit
Running Mailpit for tests
You can either run your own instance of Mailpit or use the provided docker-compose file to run one for you. To run Mailpit with Docker make sure you have Docker installed and run:
docker-compose up -d
Mailpit ports for tests
The tests expect Mailpit to listen to SMTP on port 2025 and to HTTP traffic on port 9025.
If you want different ports you can copy phpunit.xml.dist to phpunit.xml and change the port numbers in the environment variables therein.