mohrekopp / php-mailhog-client
Installs: 1 294
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: >=7.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- doctrine/collections: ^1.4
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.0
- php-http/message-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12
- guzzlehttp/psr7: ^1.0
- php-http/message: ^1.0
- php-http/mock-client: ^1.0
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ~2.6
- swiftmailer/swiftmailer: ^6.0
- symfony/dotenv: ^3.3
This package is not auto-updated.
Last update: 2024-11-18 08:56:29 UTC
README
PHP-Client for the Mailhog-API (v2) based on HTTPlug
Installation
composer require mohrekopp/php-mailhog-client
Since HTTPlug is just an abstraction, you have to install a client or an adapter, e.g. CURL-client:
composer require php-http/curl-client
Or Guzzle6-adapter:
composer require php-http/guzzle6-adapter
Usage
<?php require_once 'vendor/autoload.php'; use Mohrekopp\MailHogClient\MailHogClient; use Mohrekopp\MailHogClient\SearchCriteria; # Instantiate client $client = new MailHogClient('http://localhost:8025'); # Retrieve all messages $messages = $client->getMessages(); # Iterate over messages foreach ($messages as $message) { $message->getBody(); $message->getSubject(); } # Search for messages based on subject or body content $criteria = SearchCriteria::createContainingCriteria('Content for searching'); $messages = $client->searchMessages($criteria); # Search for messages sent *from* bob@example.com $criteria = SearchCriteria::createSentByCriteria('bob@example.com'); $client->searchMessages($criteria); # Search for messages sent *to* alice@example.com $criteria = SearchCriteria::createSentToCriteria('alice@example.com'); $client->searchMessages($criteria);
Tests
Run Unit-Tests
composer run test-unit
Run Functional-Tests
- You have to install a HTTPlug-Client:
composer require php-http/curl-client
- Copy the .env.dist file and start a docker-container for Mailhog:
cp .env.dist .env
docker-compose up -d
- Seed Mailhog with testdata and run tests
composer run test-seed-mailhog
composer run test-functional
License
The MIT License (MIT). Please see License File for more information.