spiralover / mailer-client
Webhook Mail Routing Client
0.1.3
2024-03-09 16:13 UTC
Requires
- php: ^8.2
- ext-json: *
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.4
README
Mail Router PHP Client
Getting started
composer require spiralover/mailer-client
Usage
Application Management
<?php use SpiralOver\Mailer\Client\Application; require __DIR__ . '/vendor/autoload.php'; $client = Application::client(authToken: '<authentication-token>'); // List $applications = $client->list(); // Create $created = $client->create( name: 'My Application 1', url: 'localhost:7788', webhook: 'localhost:7788/webhook', desc: 'Hello World', ); // Update $updated = $client->update( id: $created->application_id, name: 'My Application 1', url: 'localhost:7788', webhook: 'localhost:7788/webhook', desc: 'Hello World', ); // Fetch Info $viewed = $application->read('2eb91dc3-b8ad-4d41-a207-963cec055fac'); // Delete $message = $application->delete($created->neuron_id);
Sending Emails
Sending mails to receivers
<?php use GuzzleHttp\Exception\GuzzleException; use SpiralOver\Mailer\Client\Dto\Mailbox; use SpiralOver\Mailer\Client\Dto\MailData; use SpiralOver\Mailer\Client\Exceptions\RequestFailureException; use SpiralOver\Mailer\Client\Mailer; require __DIR__ . '/vendor/autoload.php'; $client = Mailer::client(authToken: '<authentication-token>'); $response = $client->send( appId: '2eb91dc3-b8ad-4d41-a207-963cec055fab', mails: [ MailData::create( subject: 'Test 001', message: 'Hello World', from: Mailbox::create( name: 'SpiralOver', email: 'noreply@spiralover.com' ), receiver: [ Mailbox::create( name: 'Jane Doe', email: 'jane.doe@spiralover.com' ) ] ) ] );
You can also specify cc, bcc & reply to
MailData::create( [...], cc: [ Mailbox::create( name: 'Jane', email: 'jane@spiralover.com' ) ], bcc: [ Mailbox::create( name: 'Shaheed', email: 'shaheed@spiralover.com' ) ], reply_to: [ Mailbox::create( name: 'Tom Tucker', email: 'tom.tucker@spiralover.com' ) ] );
Client Options
<?php use SpiralOver\Mailer\Client\Application; require __DIR__ . '/vendor/autoload.php'; $client = Application::client( authToken: '<authentication-token>', server: Application::SERVER_SPIRALOVER, apiVersion: 'v1' );
Enjoy 😎