hampel/symfonymailer-sparkpost

A Symfony Mailer Transport for SparkPost

1.1.2 2024-10-04 12:04 UTC

This package is auto-updated.

Last update: 2024-12-04 12:28:49 UTC


README

Latest Version on Packagist Total Downloads Open Issues License

By Simon Hampel

Description

Standalone implementation of Symfony Mailer SparkPost Driver based on https://github.com/gam6itko/sparkpost-mailer - but using GuzzleHttp as the HTTP client rather than Symfony HTTP Client.

Installation

You can install the package via composer:

composer require hampel/symfonymailer-sparkpost

Usage

The SparkPost options available are defined in the API: SparkPost options

$sparkpostOptions = [
	'options' => [
		'open_tracking' => false,
		'click_tracking' => true,
		'transactional' => true,
	],
];

$transport = new SparkPostApiTransport(
	'MYSPARKPOSTAPIKEY', 
	new GuzzleHttp\Client
);

new SparkPostEmail();
$email->setOptions([
    'click_tracking' => false,
    'open_tracking' => true,
    'transactional' => true,
]);
$email->setCampaignId('my-campaign');
$email->from('webmaster@example.com');
$email->to('me@example.com');
$email->subject('My subject');
$email->text(...);
$email->html(...);

$result = $transport->send($email);