A courier implementation for SparkPost.
See documentation for full details.
composer require quartzy/courier-sparkpost
You will also need to install a php-http implementation library as defined in the SparkPost docs.
<?php
use Courier\SparkPost\SparkPostCourier;
use GuzzleHttp\Client;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
use PhpEmail\Content\TemplatedContent;
use PhpEmail\EmailBuilder;
use SparkPost\SparkPost;
new Client();
$courier = new SparkPostCourier(
new SparkPost(new GuzzleAdapter(new Client()), ['key'=>'YOUR_API_KEY'])
);
$email = EmailBuilder::email()
->from('[email protected]')
->to('[email protected]')
->replyTo('[email protected]', 'Your Sales Rep')
->withSubject('Welcome!')
->withContent(new TemplatedContent('my_email', ['testKey' => 'value']))
->build();
$courier->deliver($email);
For details on building the email objects, see Php Email.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The Apache License, v2.0. Please see License File for more information.