### Install laravel-postmark via Composer Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-postmark ``` -------------------------------- ### Manage templates with Postmark::templates() Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Manage Postmark templates: list with optional count, offset, and type; get by alias; create with subject and body; update; and delete. ```php Postmark::templates()->list(); Postmark::templates()->list(count: 10, offset: 0, type: 'Standard'); Postmark::templates()->get('welcome'); Postmark::templates()->create('Welcome', 'Welcome aboard', [ 'Alias' => 'welcome', 'HtmlBody' => '

Hello {{name}}

', 'TextBody' => 'Hello {{name}}', ]); Postmark::templates()->update('welcome', ['Subject' => 'Welcome!']); Postmark::templates()->delete('welcome'); ``` -------------------------------- ### Get email statistics with Postmark::stats() Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Retrieve Postmark statistics: overview, sends with optional tag and date range, bounces, opens, clicks, and spam complaints. ```php Postmark::stats()->overview(); Postmark::stats()->sends(tag: 'welcome', fromDate: '2026-01-01', toDate: '2026-01-31'); Postmark::stats()->bounces(); Postmark::stats()->opens(); Postmark::stats()->clicks(); Postmark::stats()->spam(); ``` -------------------------------- ### Publish postmark-config Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Publish the package configuration file. ```bash php artisan vendor:publish --tag=postmark-config ``` -------------------------------- ### Configure config/postmark.php Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Configuration file for the package. `message_stream` is applied to every send and suppression call that does not pass its own, and `default_count` is the page size used by the list endpoints. ```php // config/postmark.php return [ 'api_url' => env('POSTMARK_API_URL', 'https://api.postmarkapp.com'), 'token' => env('POSTMARK_TOKEN', ''), 'message_stream' => env('POSTMARK_MESSAGE_STREAM', 'outbound'), 'default_count' => env('POSTMARK_DEFAULT_COUNT', 50), ]; ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Runs the test suite for the Laravel Postmark package. Use this command to execute all tests defined in the project. ```bash composer test ``` -------------------------------- ### Access server endpoint with Postmark::server() Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Access the server endpoint directly on the manager. ```php Postmark::server(); ``` -------------------------------- ### Manage bounces with Postmark::bounces() Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Query bounces with filters, fetch a bounce by ID, dump the raw bounce source, activate a bounced address, and retrieve delivery statistics. ```php Postmark::bounces()->list(['type' => 'HardBounce', 'inactive' => true]); Postmark::bounces()->get(692560173); Postmark::bounces()->dump(692560173); // raw bounce source Postmark::bounces()->activate(692560173); // reactivate the address Postmark::bounces()->deliveryStats(); ``` -------------------------------- ### Manage suppressions with Postmark::suppressions() Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Manage suppressions: list for the configured stream or a specific stream, create for one or multiple addresses, and delete a suppression. ```php Postmark::suppressions()->list(); // configured stream Postmark::suppressions()->list('broadcast'); Postmark::suppressions()->create('bounced@example.com'); Postmark::suppressions()->create(['a@example.com', 'b@example.com'], 'broadcast'); Postmark::suppressions()->delete('a@example.com'); ``` -------------------------------- ### Send batch emails with sendBatch and sendBatchWithTemplates Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Send a batch of raw Postmark message payloads. The configured message stream is applied to any message that does not set its own. Use sendBatchWithTemplates for template-based batch messages. ```php Postmark::sendBatch([ ['From' => 'sender@example.com', 'To' => 'a@example.com', 'Subject' => 'Hi', 'TextBody' => 'Hi'], ['From' => 'sender@example.com', 'To' => 'b@example.com', 'Subject' => 'Hi', 'TextBody' => 'Hi'], ]); Postmark::sendBatchWithTemplates([ ['From' => 'sender@example.com', 'To' => 'a@example.com', 'TemplateAlias' => 'welcome', 'TemplateModel' => ['name' => 'Ada']], ]); ``` -------------------------------- ### Send email with Postmark facade Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Send a single email via the Postmark facade. Supports up to 50 recipients per message and passes any additional Postmark fields through the $options array, such as Cc, ReplyTo, Tag, TrackOpens, TrackLinks, and MessageStream. ```php use JeffersonGoncalves\Postmark\Facades\Postmark; Postmark::sendEmail( from: 'sender@example.com', to: 'recipient@example.com', subject: 'Welcome aboard', htmlBody: '

Hello!

', ); // Several recipients (Postmark accepts up to 50 per message): Postmark::sendEmail('sender@example.com', ['a@example.com', 'b@example.com'], 'Hi', textBody: 'Hi'); // Any other Postmark field goes in $options: Postmark::sendEmail( from: 'sender@example.com', to: 'recipient@example.com', subject: 'Welcome aboard', htmlBody: '

Hello!

', options: [ 'Cc' => 'cc@example.com', 'ReplyTo' => 'reply@example.com', 'Tag' => 'welcome', 'TrackOpens' => true, 'TrackLinks' => 'HtmlAndText', 'MessageStream' => 'broadcast', ], ); ``` -------------------------------- ### Set POSTMARK_TOKEN in .env Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Set the Postmark server token in the .env file. Find it under Servers > (your server) > API Tokens in your Postmark account. ```env POSTMARK_TOKEN=your-server-token ``` -------------------------------- ### Query messages with Postmark::messages() Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Search outbound and inbound messages with filters, fetch a message by ID, and retrieve inbound message details. ```php Postmark::messages()->outbound(['tag' => 'welcome', 'status' => 'sent']); Postmark::messages()->inbound(['recipient' => 'inbox@example.com']); Postmark::messages()->get('0a129aee-e1cd-480d-b08d-4f48548ff48d'); Postmark::messages()->inboundDetails('e2ecbbfc-fe12-463d-b933-9fe22915106d'); ``` -------------------------------- ### Send email with template using sendEmailWithTemplate Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Send an email using a Postmark template. Pass an integer as TemplateId or a string as TemplateAlias; the template model is provided as an array. ```php Postmark::sendEmailWithTemplate('sender@example.com', 'recipient@example.com', 'welcome', [ 'name' => 'Ada', 'product_url' => 'https://example.com', ]); Postmark::sendEmailWithTemplate('sender@example.com', 'recipient@example.com', 1234567); ``` -------------------------------- ### Handle Postmark errors with PostmarkException Source: https://github.com/jeffersongoncalves/laravel-postmark/blob/main/README.md Catch PostmarkException when sending email. getMessage() returns Postmark's "Message", getCode() returns Postmark's "ErrorCode" or the HTTP status when absent, and errorBody() returns the full decoded error body. ```php use JeffersonGoncalves\Postmark\Exceptions\PostmarkException; try { Postmark::sendEmail('sender@example.com', 'recipient@example.com', 'Hi', textBody: 'Hi'); } catch (PostmarkException $e) { $e->getMessage(); // Postmark's "Message" $e->getCode(); // Postmark's "ErrorCode", or the HTTP status when absent $e->errorBody(); // the full decoded error body } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.