sendernet / sender-transactional-php
Sendernet transactional email php API client
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/sendernet/sender-transactional-php
Requires
- php: ^8.2
- ext-json: *
- beberlei/assert: ^3.2
- php-http/client-common: ^2.2
- php-http/discovery: ^1.9
- php-http/httplug: ^2.1
- psr/http-client-implementation: ^1.0
- psr/http-message: ^1.0 || ^2.0
- symfony/options-resolver: ^6.0 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4
- guzzlehttp/psr7: ^2.0
- http-interop/http-factory-guzzle: ^1.0
- mockery/mockery: ^1.6
- orchestra/testbench: ^9.0 || ^10.0
- php-http/guzzle7-adapter: ^1.0
- php-http/message: ^1.0
- php-http/mock-client: ^1.0
- phpunit/phpunit: ^10.0 || ^11.0 || ^12.0
Suggests
- illuminate/mail: Required for Laravel integration (^10.0 || ^11.0 || ^12.0)
- illuminate/support: Required for Laravel integration (^10.0 || ^11.0 || ^12.0)
This package is not auto-updated.
Last update: 2025-10-30 22:06:41 UTC
README
A modern PHP client for Sender.net transactional email API. The SDK provides a fluent builder for email payloads, consistent exception types, and first-class Laravel transport integration.
Table of Contents
- Requirements
- Installation
- Quick Start
- Email Features
- Error Handling
- Laravel Integration
- Testing
- License
Requirements
- PHP 8.1 or newer
- PSR-18 HTTP client implementation (e.g.
php-http/guzzle7-adapter) - PSR-17 request & stream factories (e.g.
nyholm/psr7) - SenderNet API key
Installation
Install the recommended HTTP client and factories:
composer require php-http/guzzle7-adapter nyholm/psr7
Install the SDK:
composer require sendernet/sender-transactional-php
Quick Start
use SenderNet\SenderNet; use SenderNet\Helpers\Builder\EmailParams; use SenderNet\Helpers\Builder\Recipient; $sender = new SenderNet(['api_key' => getenv('SENDER_API_KEY')]); $emailParams = (new EmailParams()) ->setFrom('no-reply@example.com') ->setFromName('Example App') ->setRecipients([new Recipient('user@example.com', 'User')]) ->setSubject('Welcome') ->setText('Thanks for signing up\!'); $response = $sender->email->send($emailParams);
Additional recipes are available in GUIDE.md.
Email Features
- Single primary recipient enforced by validation (
setRecipients()must receive exactly one entry). - Content options for HTML, text and custom headers.
- Attachments using
setAttachments().
Error Handling
- All HTTP failures raise subclasses of
SenderNet\Exceptions\SenderNetRequestExceptionexposing the original PSR-7 request and response. - Validation problems surface as
SenderNetValidationException, which provides:getErrors()for the raw payload array.getErrorMessages()for formatted strings (e.g.field: message).getFirstError()for the first human-readable issue.
- Rate limiting throws
SenderNetRateLimitExceptionincludingRetry-Aftermetadata.
Laravel Integration
The package provides a Laravel mail transport so you can send messages using the familiar Mail facade.
-
Install the SDK (auto-discovery registers
SenderServiceProvider). -
Run the installer for guided setup:
php artisan sender:install
-
Configure environment variables:
SENDER_API_KEY=your_api_key MAIL_MAILER=sender
-
Use Laravel's mailing features as usual. Any
SenderNetRequestExceptionraised by the SDK is converted intoSymfony\Component\Mailer\Exception\TransportExceptionwith the original message preserved.
Testing
composer exec phpunit
License
Released under the MIT License.