2017 © Pedro Peláez
 

library laravel-sparkposthooks

A simple SparkPost webhook controller to help with events. Compatible with Laravel 5+ and Lumen 5+.

image

brentnd/laravel-sparkposthooks

A simple SparkPost webhook controller to help with events. Compatible with Laravel 5+ and Lumen 5+.

  • Friday, May 25, 2018
  • by brentnd
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 50 % Grown

The README.md

Laravel 5 / Lumen 5 SparkPost Webhook Controller

Latest Version Software License Total Downloads, (*1)

A simple SparkPost webhook controller to help with email events. Useful for notifying users that you cannot reach them via email inside your application. Compatible with Laravel 5+ and Lumen 5+., (*2)

Installation

composer require brentnd/laravel-sparkposthooks, (*3)

Basic Usage

1) Create a controller that extends SparkPostWebhookController as follows. You can then handle any SparkPost webhook event., (*4)

use Brentnd\Api\Webhooks\SparkPostWebhookController;

class MySparkPostController extends SparkPostWebhookController {

    /**
     * Handle a bounced email
     *
     * @param $payload
     */
    public function handleMessageEventBounce($payload)
    {
        $email = $payload['rcpt_to'];
    }

    /**
     * Handle a rejected email
     *
     * @param $payload
     */
    public function handleMessageEventPolicyRejection($payload)
    {
        $email = $payload['rcpt_to'];
    }

    /**
     * Handle an email open
     *
     * @param $payload
     */
    public function handleTrackEventOpen($payload)
    {
        $transmissionId = $payload['transmission_id'];
    }
}

2) Create the route to handle the webhook. In your routes.php file add the following., (*5)

post('sparkpost-webhook', ['as' => 'sparkpost.webhook', 'uses' => 'MySparkPostController@handleWebhook']);

3) Exclude your route from CSRF protection so it will not fail., (*6)

4) Make sure you add your webhook in SparkPost to point to your route. You can do this here: https://app.sparkpost.com/webhooks, (*7)

Webhook Events

Webhook event types:, (*8)

Common events and their handlers. For other events, just follow the same pattern., (*9)

Event type Event Method
Ping - handlePing()
Message Events Bounce handleMessageEventBounce()
Message Events Delivery handleMessageEventDelivery()
Message Events Injection handleMessageEventInjection()
Message Events Policy Rejection handleMessageEventPolicyRejection()
Message Events Delay handleMessageEventDelay()
Engagement Events Click handleTrackEventClick()
Engagement Events Open handleTrackEventOpen()
Engagement Events Initial Open handleTrackEventInitialOpen()
Unsubscribe Events List Unsubscribe handleUnsubscribeEventListUnsubscribe()
Unsubscribe Events Link Unsubscribe handleUnsubscribeEventLinkUnsubscribe()

Contributors

Based on eventhomes/laravel-mandrillhooks, (*10)

The Versions

25/05 2018

dev-master

9999999-dev

A simple SparkPost webhook controller to help with events. Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Brent Dimmig

laravel mail lumen webhooks sparkpost

25/05 2018

dev-develop

dev-develop

A simple SparkPost webhook controller to help with events. Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Brent Dimmig

laravel mail lumen webhooks sparkpost

25/05 2018

v1.0.0

1.0.0.0

A simple SparkPost webhook controller to help with events. Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Brent Dimmig

laravel mail lumen webhooks sparkpost