stidges/laravel-sparkpost-transport

Sparkpost transport for Laravel 11.x

v3.0.0 2024-09-01 13:02 UTC

This package is auto-updated.

Last update: 2024-10-31 13:24:52 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Sparkpost transport for Laravel 11.x

Note: use v1 of this package for Laravel 9.x support Note: use v2 of this package for Laravel 10.x support

Installation

You can install the package via composer:

composer require stidges/laravel-sparkpost-transport

Usage

1. Configuration

To get started, update your config/services.php with your Sparkpost secret key like so:

<?php

return [
    // ...
    'sparkpost' => [
        'secret' => env('SPARKPOST_SECRET'),
    ],
];

Next, add the Sparkpost transport to the mailers section of your config/mail.php:

<?php

return [
    // ...
    'mailers' => [
        // ...
        'sparkpost' => [
            'transport' => 'sparkpost',
        ],
    ],
    // ...
];

And finally, update your .env file to add the SPARKPOST_SECRET and to update the MAIL_MAILER:

MAIL_MAILER=sparkpost

SPARKPOST_SECRET=YourSecretKey

2. Customizing the Sparkpost API domain

If you'd like to use the EU domain for Sparkpost, you can add the domain to your config/services.php file:

'sparkpost' => [
    'secret' => env('SPARKPOST_SECRET'),
    'domain' => 'api.eu.sparkpost.com',
],

3. Customizing Sparkpost Transmission API options

You can add a options array to your config/services.php to add any data you would like to send to the Sparkpost API. Any data in the options array will be merged into the API request body. For details on how you can customize the transmission, review the Sparkpost API documentation

'sparkpost' => [
    'secret' => env('SPARKPOST_SECRET'),
    'options' => [
        'campaign_id' => 'my_campaign_id',
        'options' => [
            'click_tracking' => false,
        ],
    ],
],

4. Customizing the Guzzle client

You can add any options to the Guzzle client by adding a guzzle array to your config/services.php file:

'sparkpost' => [
    'secret' => env('SPARKPOST_SECRET'),
    'guzzle' => [
        'timeout' => 10,
    ],
],

Credits

License

The MIT License (MIT). Please see License File for more information.