hampel/symfonymailer-sparkpost

A Symfony Mailer Transport for SparkPost

1.1.1 2024-09-09 07:19 UTC

This package is auto-updated.

Last update: 2024-09-09 07:20:35 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);