{"id":21524216,"url":"https://github.com/mvdnbrk/laravel-postmark-webhooks","last_synced_at":"2025-04-13T10:31:01.861Z","repository":{"id":33007701,"uuid":"149487979","full_name":"mvdnbrk/laravel-postmark-webhooks","owner":"mvdnbrk","description":"Handle Postmark webhooks in a Laravel application.","archived":false,"fork":false,"pushed_at":"2024-08-08T19:13:43.000Z","size":299,"stargazers_count":25,"open_issues_count":5,"forks_count":11,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T01:51:30.682Z","etag":null,"topics":["e-mail","laravel","postmark","webhooks"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvdnbrk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mvdnbrk"}},"created_at":"2018-09-19T17:31:58.000Z","updated_at":"2024-05-30T18:02:32.000Z","dependencies_parsed_at":"2024-11-24T02:16:49.869Z","dependency_job_id":null,"html_url":"https://github.com/mvdnbrk/laravel-postmark-webhooks","commit_stats":{"total_commits":230,"total_committers":3,"mean_commits":76.66666666666667,"dds":0.008695652173912993,"last_synced_commit":"96e9eef021a3f6cb36f10f10b3bf20505a7f8909"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Flaravel-postmark-webhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Flaravel-postmark-webhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Flaravel-postmark-webhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Flaravel-postmark-webhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvdnbrk","download_url":"https://codeload.github.com/mvdnbrk/laravel-postmark-webhooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248698770,"owners_count":21147522,"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":["e-mail","laravel","postmark","webhooks"],"created_at":"2024-11-24T01:22:54.034Z","updated_at":"2025-04-13T10:31:01.818Z","avatar_url":"https://github.com/mvdnbrk.png","language":"PHP","funding_links":["https://github.com/sponsors/mvdnbrk"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://postmarkapp.com\" target=\"_blank\"\u003e\u003cimg src=\"https://postmarkapp.com/images/logo.svg\" alt=\"Postmark Inbound\" width=\"240\" height=\"40\"\u003e\u003c/a\u003e\n\n# Handle Postmark webhooks in a Laravel application\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Tests][ico-tests]][link-tests]\n[![StyleCI][ico-style-ci]][link-style-ci]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nPostmark can send out several webhooks to *your* application when an event occurs.  \nThis way Postmark is able to immediately notify you when something new occurs.\n\nThis package can help you handle those webhooks.\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require mvdnbrk/laravel-postmark-webhooks\n```\n\nThis package will log all incoming webhooks to the database by default.  \nRun the migrations to create a `postmark_webhook_logs` table in the database:\n\n``` bash\nphp artisan migrate\n```\n\u003e If you want to disable database logging you can set `POSTMARK_WEBHOOKS_LOG_ENABLED=false` in your `.env` file. \n\n## Setup webhooks with Postmark\n\nVisit the [servers](https://account.postmarkapp.com/servers) page on your [Postmark account](https://account.postmarkapp.com/).\nChoose the server you want to setup webhooks for.  \nGo to `settings` \u003e `webhooks` \u003e `add webbook`.  \n\nThis package will register a route where Postmark can post their webhooks to: `/api/webhooks/postmark`.\n\nFill in your webhook URL: `https://\u003cyour-domain.com\u003e/api/webhooks/postmark`  \nPick the events Postmark should send to you and save the webhook.  \nYou are ready to receive webhook notifications from Postmark!\n\n\u003e You may change the `/api/webhooks/postmark` endpoint to anything you like.  \n\u003e You can do this by changing the `path` key in the `config/postmark-webooks.php` file.\n\n## Protection of your webhook\n\nThis package protects your webhook automatically by only allowing requests from the [IP range](https://postmarkapp.com/support/article/800-ips-for-firewalls#webhooks) that Postmark uses.\n\n## Usage\n\nPostmark can send out several event types by posting a webhook.  \nYou can find the [full list of webhooks](https://postmarkapp.com/developer/webhooks/webhooks-overview) in the Postmark documentation.\n\nAll webhook requests will be logged in the `postmark_webhook_logs` table.  \nThe table has a `payload` column where the entire payload of the incoming webhook is saved.  \nThe ID Postmark assigned to the original message will be saved in the `message_id` column,  \nthe event type will be stored in the `record_type` column and the email address as well in the `email` column.\n\u003e Note that event types will be converted to `snake_case`.  \nFor example `SpamComplaint` will be saved as `spam_complaint`.\n\n### Events\n\nWhenever a webhook call comes in, this package will fire a `PostmarkWebhookCalled` event.  \nYou may register an event listener in the `EventServiceProvider`:\n\n```php\n/**\n * The event listener mappings for the application.\n *\n * @var array\n */\nprotected $listen = [\n    PostmarkWebhookCalled::class =\u003e [\n        YourListener::class,\n    ],\n];\n```\n\nExample of a listener:\n\n```php\n\u003c?php\n\nnamespace App\\Listeners;\n\nuse Mvdnbrk\\PostmarkWebhooks\\Events\\PostmarkWebhookCalled;\n\nclass YourListener\n{\n    /**\n     * Handle the event.\n     *\n     * @param  \\Mvdnbrk\\PostmarkWebhooks\\Events\\PostmarkWebhookCalled  $event\n     * @return void\n     */\n    public function handle(PostmarkWebhookCalled $event)\n    {\n        // Do your work here.\n\n        // You can access the payload here with: $event-\u003epayload.\n        // The email address, message ID and record type are also available:\n        // $event-\u003eemail\n        // $event-\u003emessageId\n        // $event-\u003erecordType\n    }\n}\n\n```\n\nYou may also register an event listener for a specific type of event:\n\n```php\n/**\n * The event listener mappings for the application.\n *\n * @var array\n */\nprotected $listen = [\n    'webhook.postmark: spam_complaint' =\u003e [\n        YourSpamComplaintListener::class,\n    ],\n];\n```\n\nAvailable events: `open`, `bounce`, `click`, `delivery`, `spam_complaint`.\n\n### Advanced configuration\n\nYou may optionally publish the config file with:\n\n```bash\nphp artisan vendor:publish --provider=\"Mvdnbrk\\PostmarkWebhooks\\PostmarkWebhooksServiceProvider\" --tag=\"config\"\n```\n\nWithin the configuration file you may change the table name being used \nor the Eloquent model being used to save log records to the database.\n\u003e If you want to use your own model to save the logs to the database you should extend\nthe `Mvdnbrk\\PostmarkWebhooks\\PostmarkWebhook` class.\n\nYou can also exclude one or more event types from being logged to the database.  \nPlace the events you want to exclude under the `except` key:\n\n```php\n'log' =\u003e [\n    ...\n    'except' =\u003e [\n        'open',\n        ...\n    ],\n],\n```\n\nYou can map the events fired by this package to your own event classes:\n\n```php\n'events' =\u003e [\n    'spam_complaint' =\u003e App\\Events\\SpamComplaint,\n    ...\n],\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md)  for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Mark van den Broek][link-author]\n- [All Contributors][link-contributors]\n\nInspired by [Laravel Stripe Webooks](https://github.com/spatie/laravel-stripe-webhooks) from [Spatie](https://spatie.be/).\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/mvdnbrk/laravel-postmark-webhooks.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-tests]: https://img.shields.io/github/workflow/status/mvdnbrk/laravel-postmark-webhooks/tests/main?label=tests\u0026style=flat-square\n[ico-style-ci]: https://styleci.io/repos/149487979/shield?branch=main\n[ico-downloads]: https://img.shields.io/packagist/dt/mvdnbrk/laravel-postmark-webhooks.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/mvdnbrk/laravel-postmark-webhooks\n[link-tests]: https://github.com/mvdnbrk/laravel-postmark-webhooks/actions?query=workflow%3Atests\n[link-style-ci]: https://styleci.io/repos/149487979\n[link-downloads]: https://packagist.org/packages/mvdnbrk/laravel-postmark-webhooks\n[link-author]: https://github.com/mvdnbrk\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdnbrk%2Flaravel-postmark-webhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvdnbrk%2Flaravel-postmark-webhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdnbrk%2Flaravel-postmark-webhooks/lists"}