Download the PHP package stechstudio/laravel-email-events without Composer
On this page you can find all versions of the php package stechstudio/laravel-email-events. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stechstudio/laravel-email-events
More information about stechstudio/laravel-email-events
Files in stechstudio/laravel-email-events
Package laravel-email-events
Short Description Handle email event webhooks
License MIT
Homepage https://github.com/stechstudio/laravel-email-events
Informations about the package laravel-email-events
Email event webhook processing
So you have your Laravel app sending email out through SendGrid or Mailgun or Postmark, super. Now you want to capture webhooks and react to email events, such as deliveries or bounces. This is where it can get a bit messy, authorizing the webhook submission, parsing the payload, handling the details... and then of course you've tied yourself to one particular email provider.
This package greatly simplifies the process. It will accept webhook submissions from any supported email provider, authorize the submission, generalize it to a standard data format, and fire off a Laravel event. Now all you have to do is listen for an event and go!
Installation
Via Composer
Quick start
1. Add the routes
In your routes/web.php
file add:
This will wire up a route at .hooks/email-events/{provider}
.
2. Configure your auth method
There are multiple authorization options available. The default option (and works with any provider) is just a URL token.
In your app .env file set a token secret:
3. Configure your mail provider with your webhook endpoint
Log in to your email provider account, find the webhook section, and add your URL endpoint. Make sure to specify the provider name, and include the auth token.
For example, if you are using SendGrid you would go to the Mail Settings page, turn on the "Event Notification" setting, check all the actions that you care about, and provide your POST URL:
Note while in local/development mode you can use
valet share
to get a publicly accessible domain for your app.
4. Listen for the event
Lastly, you need to listen for an email event in your app. Setup an event listener and listen for STS\EmailEvents\EmailEvent
.
Something like this: