### Install Orboto Mail PHP SDK Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Install the SDK using Composer. Requires PHP 8.2+ and a PSR-18 HTTP client. ```bash composer require orboto/mail ``` -------------------------------- ### Quick Start: Send an Email Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Initialize the OrbotoMail client with your API key and send a single email. Access the message ID, status, and quota usage from the result. ```php use Orboto\Mail\OrbotoMail; $mail = new OrbotoMail(['apiKey' => $_ENV['OMS_API_KEY']]); $result = $mail->send([ 'from' => 'noreply@acme.orbo.to', 'to' => 'user@example.com', 'subject' => 'Welcome', 'html' => '
Hi {{name}}!
', 'variablesSchema' => [ 'type' => 'object', 'required' => ['name', 'company'], 'properties' => [ 'name' => ['type' => 'string'], 'company' => ['type' => 'string'], ], ], ]); $mail->sendTemplate([ 'templateId' => $tpl->id, 'to' => 'user@example.com', 'variables' => ['name' => 'Ada', 'company' => 'ACME'], ]); ``` -------------------------------- ### API Reference - Webhooks Resource Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Manage webhook configurations. Supports listing, retrieving, creating, updating, removing webhooks, and rotating the secret key. ```APIDOC ## API reference | Resource | Methods | |---|---| | `$mail->webhooks` | `list`, `get`, `create`, `update`, `remove`, `rotateSecret` | ``` -------------------------------- ### Send a Batch of Emails Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Send multiple emails in a single request, capped at 100 messages. Inspect the batch results for individual success or failure, and check the summary for overall counts. ```php $batch = $mail->sendBatch([ 'messages' => [ ['from' => 'a@x.com', 'to' => 'u1@example.com', 'subject' => 'Hi 1', 'text' => 'Hello 1'], ['from' => 'a@x.com', 'to' => 'u2@example.com', 'subject' => 'Hi 2', 'text' => 'Hello 2'], ], ]); foreach ($batch->results as $item) { if (!$item->ok) { error_log("Send #{$item->index} failed: {$item->reason}"); } } echo "{$batch->summary->queued} queued, {$batch->summary->suppressed} suppressed."; ``` -------------------------------- ### Register Quota Lifecycle Event Listeners Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Attach listeners to specific quota events like 'quota-warning', 'quota-low', 'quota-exhausted', and 'connection-revoked'. These events fire once per quota-reset period. ```php use Orboto\Mail\Dto\QuotaState; use Orboto\Mail\Dto\ConnectionRevokedEvent; $mail->on('quota-warning', fn (QuotaState $q) => error_log("80%: {$q->current}/{$q->total}")); $mail->on('quota-low', fn (QuotaState $q) => error_log("95%: {$q->current}/{$q->total}")); $mail->on('quota-exhausted', fn (QuotaState $q) => error_log("100%: tier cap hit")); $mail->on('connection-revoked', fn (ConnectionRevokedEvent $e) => error_log("disabled: {$e->message}")); ``` -------------------------------- ### API Reference - Templates Resource Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Manage email templates. Operations include listing, retrieving, creating, updating, and removing templates. ```APIDOC ## API reference | Resource | Methods | |---|---| | `$mail->templates` | `list`, `get`, `create`, `update`, `remove` | ``` -------------------------------- ### Top-Level Send Methods Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Direct methods for sending emails, including single sends, batch sends, template-based sends, and retrieving quota information. ```APIDOC ## API reference Plus top-level send methods: `send`, `sendBatch`, `sendTemplate`, `getQuota`. ``` -------------------------------- ### API Reference - API Keys Resource Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Manage API keys for your Orboto account. Operations include listing, retrieving, creating, revoking, and rotating keys. ```APIDOC ## API reference | Resource | Methods | |---|---| | `$mail->apiKeys` | `list`, `get`, `create`, `revoke`, `rotate` | ``` -------------------------------- ### Laravel Integration - Sending Mail Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Send emails using the Orboto Mail SDK within a Laravel application via the Facade. ```APIDOC ## Laravel The SDK ships a Service-Provider + Facade + Notification Channel for Laravel 11+. Auto-discovery wires them in on `composer require`. Publish the config: ```bash php artisan vendor:publish --tag=orboto-mail-config ``` Then in code: ```php use Orboto\Mail\Laravel\OrbotoMailFacade as OrbotoMail; OrbotoMail::send([ 'from' => config('mail.from.address'), 'to' => $user->email, 'subject' => 'Welcome', 'html' => view('mail.welcome', ['user' => $user])->render(), ]); ``` ``` -------------------------------- ### Implement OrbotoMailChannel for Laravel Notifications Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Integrate Orboto Mail as a notification channel in Laravel. This involves defining the 'via' method to return OrbotoMailChannel::class and implementing 'toOrbotoMail' to return the email payload. This allows using Orboto Mail for sending notifications. ```php use Orboto\Mail\Laravel\OrbotoMailChannel; class Welcome extends Notification { public function via($notifiable): array { return [OrbotoMailChannel::class]; } public function toOrbotoMail($notifiable): array { return [ 'from' => 'noreply@acme.orbo.to', 'to' => $notifiable->email, 'subject' => 'Welcome to ACME', 'html' => view('mail.welcome', ['user' => $notifiable])->render(), ]; } } ``` -------------------------------- ### API Reference - Inbound Resource Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Access inbound email data. Supports listing and retrieving inbound email records. ```APIDOC ## API reference | Resource | Methods | |---|---| | `$mail->inbound` | `list`, `get` | ``` -------------------------------- ### API Reference - Suppression Resource Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Manage email suppression lists. Available methods include checking, adding, removing, and listing suppressed email addresses. ```APIDOC ## API reference All resources are accessible as public properties on the `OrbotoMail` instance: | Resource | Methods | |---|---| | `$mail->suppression` | `check`, `add`, `remove`, `list` | ``` -------------------------------- ### Laravel Integration - Notification Channel Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Integrate Orboto Mail as a Notification Channel in Laravel for sending notifications. ```APIDOC ## Laravel Or as a Notification Channel: ```php use Orboto\Mail\Laravel\OrbotoMailChannel; class Welcome extends Notification { public function via($notifiable): array { return [OrbotoMailChannel::class]; } public function toOrbotoMail($notifiable): array { return [ 'from' => 'noreply@acme.orbo.to', 'to' => $notifiable->email, 'subject' => 'Welcome to ACME', 'html' => view('mail.welcome', ['user' => $notifiable])->render(), ]; } } ``` ``` -------------------------------- ### Handle Orboto Mail Exceptions Source: https://github.com/orboto/orboto-mail-php/blob/develop/README.md Catch specific exceptions like QuotaExhaustedException, SuppressedRecipientException, and ConnectionRevokedException for granular error handling. A generic OrbotoMailException catches other API errors. ```php use Orboto\Mail\Exception\OrbotoMailException; use Orboto\Mail\Exception\QuotaExhaustedException; use Orboto\Mail\Exception\SuppressedRecipientException; use Orboto\Mail\Exception\ConnectionRevokedException; try { $mail->send([...]); } catch (QuotaExhaustedException $e) { // Render "upgrade your plan" — $e->getRemainingQuota() has the snapshot } catch (SuppressedRecipientException $e) { // Skip + log — recipient on suppression list } catch (ConnectionRevokedException $e) { // Disable the integration UX } catch (OrbotoMailException $e) { // Generic fallback if ($e->isRetryable()) { /* server-side transient */ } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.