stidges / laravel-sparkpost-transport
Sparkpost transport for Laravel 11.x
Installs: 12 097
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.5
- illuminate/contracts: ^11.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
README
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.