{"id":16674637,"url":"https://github.com/mateusjunges/laravel-postmark-api","last_synced_at":"2026-04-27T13:32:33.186Z","repository":{"id":65030946,"uuid":"546374771","full_name":"mateusjunges/laravel-postmark-api","owner":"mateusjunges","description":"Postmark API Client for Laravel Apps","archived":false,"fork":false,"pushed_at":"2024-01-28T23:06:40.000Z","size":196,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-01-19T20:47:16.396Z","etag":null,"topics":["email","laravel","laravel-package","php8","postmark"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mateusjunges.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-10-06T01:32:45.000Z","updated_at":"2024-10-20T06:44:29.000Z","dependencies_parsed_at":"2024-01-29T00:20:51.805Z","dependency_job_id":"f08ca743-c99f-452e-ab1f-ed14fe2f3be5","html_url":"https://github.com/mateusjunges/laravel-postmark-api","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusjunges%2Flaravel-postmark-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusjunges%2Flaravel-postmark-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusjunges%2Flaravel-postmark-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mateusjunges%2Flaravel-postmark-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mateusjunges","download_url":"https://codeload.github.com/mateusjunges/laravel-postmark-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243331589,"owners_count":20274284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","laravel","laravel-package","php8","postmark"],"created_at":"2024-10-12T12:43:44.219Z","updated_at":"2025-12-28T13:27:24.322Z","avatar_url":"https://github.com/mateusjunges.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Postmark API Client for Laravel apps\n\n- [Installation](#installation)\n  - [Configuration](#configuration)\n- [Postmark API](#postmark-api)\n  - [Emails API](#email-api)\n    - [Sending single emails](#sending-single-emails)\n    - [Sending batch emails](#sending-batch-emails)\n    - [Sending single emails with template](#sending-single-messages-with-template)\n    - [Sending batch emails with template](#sending-batch-messages-with-template)\n  - [Templates API](#templates-api)\n    - [Create template](#create-template)\n    - [Search for specific template](#search-a-specific-template)\n    - [List all templates](#get-all-templates)\n\n## Installation\nYou can install this package using composer:\n\n```bash\ncomposer require mateusjunges/laravel-postmark-api\n```\n\n### Configuration\nAll requests to Postmark’s API require you to authenticate yourself to the service. In order to do this you must send the correct HTTP header with the correct API token. So, once the package is installed, you need to add a `POSTMARK_TOKEN` key to your `.env` file. You can get your API Token from the [Postmark API Tokens tab](https://account.postmarkapp.com/api_tokens).\n\n\n## Postmark API\nAt this moment, this package provides two APIs: [`emails`](https://postmarkapp.com/developer/api/email-api) and [`templates`](https://postmarkapp.com/developer/api/templates-api).\n\nAll API calls are managed by the `Postmark` facade.\n\n\n### Email API\nThis API is responsible for sending emails with Postmark through a specific server.\n\nTo get access to the `emails` API, you must use the `messages` method, available with the `Postmark` facade:\n\n```php\n\\Junges\\Postmark\\Facades\\Postmark::messages();\n```\nThis returns a `MessageApi` contract, which is responsible for handling emails.\n\n#### Sending single emails\nTo send single emails, you should use the `send` method, which accepts a `$message` argument, that must be an instance of `Junges\\Postmark\\Api\\Message\\Requests\\Message`:\n\n\n```php\nuse Junges\\Postmark\\Facades\\Postmark;\nuse Junges\\Postmark\\Api\\Message\\Requests\\Message;\nuse Junges\\Postmark\\Api\\Message\\Requests\\Address;\n\n$message = (new Message())\n    -\u003esetFromAddress(new Address('from@example.com', 'From Name'))\n    -\u003eaddToAddress(new Address('recipient@example.com'))\n    -\u003esetSubject('Email subject')\n    -\u003esetTextBody('This is the body of the email, in text format')\n    -\u003esetHtmlBody('\u003chtml\u003eThis is the body of the email, in html format\u003c/html\u003e')\n    -\u003esetTrackLinks(\\Junges\\Postmark\\Enums\\TrackLinksEnum::HTML_AND_TEXT) // Determine which type of links should be tracked\n    -\u003esetOpenTracking(true) // Determine that the openings should be tracked\n    -\u003eaddTag('Email tag');\n \n\n$response = Postmark::messages()-\u003esend($message); // Returns an instance of `\\Junges\\Postmark\\Models\\Message\\SendResponse`\n```\n\n#### Sending batch emails\nTo send batch emails you just need to use a different method from the `MessageApi` class, passing a `Batch` containing all of your messages (up to 500 max) as parameter:\n\n```php\nuse Junges\\Postmark\\Api\\Message\\Requests\\Message;\nuse Junges\\Postmark\\Api\\Message\\Requests\\Batch;\nuse Junges\\Postmark\\Facades\\Postmark;\nuse Junges\\Postmark\\Api\\Message\\Requests\\Address;\n\n$message1 = (new Message())\n    -\u003esetFromAddress(new Address('from@example.com', 'From Name'))\n    -\u003eaddToAddress(new Address('recipient@example.com'))\n    -\u003esetSubject('Email subject')\n    -\u003esetTextBody('This is the body of the email, in text format')\n    -\u003esetHtmlBody('\u003chtml\u003eThis is the body of the email, in html format\u003c/html\u003e')\n    -\u003esetTrackLinks(\\Junges\\Postmark\\Enums\\TrackLinksEnum::HTML_AND_TEXT) // Determine which type of links should be tracked\n    -\u003esetOpenTracking(true) // Determine that the openings should be tracked\n    -\u003eaddTag('Email tag');\n\n$message2 = (new Message())\n    -\u003esetFromAddress(new Address('from@example.com', 'From Name'))\n    -\u003eaddToAddress(new Address('recipient2@example.com'))\n    -\u003esetSubject('Email subject 2')\n    -\u003esetTextBody('This is the body of the second email, in text format')\n    -\u003esetHtmlBody('\u003chtml\u003eThis is the body of the second email, in html format\u003c/html\u003e')\n    -\u003esetTrackLinks(\\Junges\\Postmark\\Enums\\TrackLinksEnum::HTML_AND_TEXT) // Determine which type of links should be tracked\n    -\u003esetOpenTracking(true) // Determine that the openings should be tracked\n    -\u003eaddTag('Email tag');\n\n$batch = new Batch();\n$batch-\u003epush($message1);\n$batch-\u003epush($message2);\n\n$response = Postmark::messages()-\u003esendBatch($batch); // Returns an Junges\\Postmark\\Models\\Message\\SendBatchResponse instance\n```\n\n#### Sending single messages with Template\nTo send single messages using a template, use the `sendWithTemplate` method, which accepts an instance of `Junges\\Postmark\\Api\\Message\\Requests\\EmailWithTemplate` as parameter:\n\n```php\nuse Junges\\Postmark\\Facades\\Postmark;\nuse Junges\\Postmark\\Api\\Message\\Requests\\EmailWithTemplate;\nuse Junges\\Postmark\\Api\\Message\\Requests\\Address;\n\n$message = (new EmailWithTemplate())\n    -\u003esetTemplateId(1234) // The ID of the template to be used \n    -\u003esetTemplateAlias('Alias_1234') // The Alias of the template to be used (not necessary when using `setTemplateId`\n    -\u003esetFromAddress(new Address('from@example.com', 'From Name'))\n    -\u003eaddToAddress(new Address('recipient@example.com'))\n    -\u003eaddTag('Message tag');\n    \nPostmark::messages()-\u003esendWithTemplate($message); // Returns an instance of `Junges\\Postmark\\Models\\Message\\SendWithTemplateResponse`\n```\n\n#### Sending batch messages with template\nTo send single messages using a template, use the `sendBatchWithTemplate` method, which accepts an instance of `Junges\\Postmark\\Api\\Message\\Requests\\BatchWithTemplate` as parameter:\n\n```php\nuse Junges\\Postmark\\Facades\\Postmark;\nuse Junges\\Postmark\\Api\\Message\\Requests\\EmailWithTemplate;\nuse Junges\\Postmark\\Api\\Message\\Requests\\BatchWithTemplate;\nuse Junges\\Postmark\\Api\\Message\\Requests\\Address;\n\n$message1 = (new EmailWithTemplate())\n    -\u003esetTemplateId(1234) // The ID of the template to be used \n    -\u003esetTemplateAlias('Alias_1234') // The Alias of the template to be used (not necessary when using `setTemplateId`\n    -\u003esetFromAddress(new Address('from@example.com', 'From Name'))\n    -\u003eaddToAddress(new Address('recipient@example.com'))\n    -\u003eaddTag('Message tag');\n    \n$message2 = (new EmailWithTemplate())\n    -\u003esetTemplateId(1234) // The ID of the template to be used \n    -\u003esetTemplateAlias('Alias_1234') // The Alias of the template to be used (not necessary when using `setTemplateId`\n    -\u003esetFromAddress(new Address('from@example.com', 'From Name'))\n    -\u003eaddToAddress(new Address('recipient2@example.com'))\n    -\u003eaddTag('Message tag 2');\n    \n$batch = new BatchWithTemplate();\n$batch-\u003epush($message1);\n$batch-\u003epush($message2);\n\nPostmark::messages()-\u003esendBatchWithTemplate($batch); // Returns an instance of `Junges\\Postmark\\Models\\Message\\SendBatchWithTemplateResponse`\n```\n\n### Templates API\nThis API lets you manage templates for a specific server.\n\n\u003e **Warning**\n\u003e \n\u003e A server may have up to 100 templates. Requests that exceed this limit won't be processed. Please [contact support](https://postmarkapp.com/contact) if you need mor templates within a Server.\n\nTo have access to the `templates` API, you must use the `templates` method, available with the `Postmark` facade:\n\n```php\n\\Junges\\Postmark\\Facades\\Postmark::templates();\n```\n\nThis returns a `TemplateApi` contract, responsible for handling template API calls.\n\n#### Create template\nTo create a template, you must use the `create` method, which accepts a `Junges\\Postmark\\Api\\Template\\Requests\\Template` parameter:\n\n```php\nuse Junges\\Postmark\\Facades\\Postmark;\nuse Junges\\Postmark\\Api\\Template\\Requests\\Template;\n\n$template = (new Template())\n    -\u003esetHtmlBody('\u003chtml\u003e\u003c/html\u003e') //The content to use for the HtmlBody when this template is used to send email.\n    -\u003esetTextBody('text') //The content to use for the TextBody when this template is used to send email.\n    -\u003esetSubject('Email subject')\n    -\u003esetAlias('The alias of the template')\n    -\u003esetName('The name of the template');\n\nPostmark::templates()-\u003ecreate($template); // Returns an instance of `Junges\\Postmark\\Models\\Template\\CreateResponse`\n```\n\n#### Search a specific template\nYou may search for a specific template using the `find` method, which accepts the template id or alias as parameter:\n\n```php\nuse Junges\\Postmark\\Facades\\Postmark;\n\nPostmark::templates()-\u003efind($templateIdOrAlias); // Returns an instance of `Junges\\Postmark\\Models\\Template\\ShowResponse`\n```\n\n#### Get all templates\nTo get a collection with all of your stored templates, use the `all` method:\n\n```php\nuse Junges\\Postmark\\Facades\\Postmark;\n\nPostmark::templates()-\u003eall(); // Returns an instance of `Junges\\Postmark\\Models\\Template\\IndexResponse`\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateusjunges%2Flaravel-postmark-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmateusjunges%2Flaravel-postmark-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmateusjunges%2Flaravel-postmark-api/lists"}