2017 © Pedro Peláez
 

symfony-bundle sparkpost-bundle

The SparkPostBundle integrates the SparkPost PHP library with Symfony, allowing you to interact with the Sparkpost API in your Symfony projects.

image

tlamedia/sparkpost-bundle

The SparkPostBundle integrates the SparkPost PHP library with Symfony, allowing you to interact with the Sparkpost API in your Symfony projects.

  • Thursday, February 8, 2018
  • by tlamedia
  • Repository
  • 1 Watchers
  • 0 Stars
  • 112 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 173 % Grown

The README.md

SparkPostBundle

The SparkPostBundle integrates the SparkPost PHP library with Symfony., (*1)

Latest Stable Version Build Status License, (*2)

Installation

Get the bundlle:, (*3)

composer require tlamedia/sparkpost-bundle, (*4)

Then enable it in your kernel:, (*5)

// config/bundles.php
return [
    //...
    Tla\SparkPostBundle\TlaSparkPostBundle::class => ['all' => true],
    //...
];

Configuration

Configure the API key to use:, (*6)

# config/packages/tla_spark_post.yml
tla_spark_post:
    api_key: 'YOUR_API_KEY' # Replace with your own

Usage

The bundle registers the service tla_spark_post.api_client, which allows you to use the SparkPost API., (*7)

Send a mail from a controller

class SomeController extends Controller
{
    public function sendAction()
    {

        $sparky = $this->getContainer()->get('tla_spark_post.api_client');

        $promise = $sparky->transmissions->post([

            'content' => [
                'from' => [
                    'name' => 'YOUR_NAME',
                    'email' => 'YOUR_EMAIL',
                ],
                'subject' => 'My first mail using SparkPostBundle',
                'html' => '<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your first mail!</p></body></html>',
                'text' => 'Congratulations, {{name}}!! You just sent your first mail!',

            ],
            'substitution_data' => ['name' => 'YOUR_FIRST_NAME'],
            'recipients' => [
                [
                    'address' => [
                        'name' => 'YOUR_NAME',
                        'email' => 'YOUR_EMAIL',
                    ],
                ],
            ],
            'cc' => [
                [
                    'address' => [
                        'name' => 'ANOTHER_NAME',
                        'email' => 'ANOTHER_EMAIL',
                    ],
                ],
            ],
            'bcc' => [
                [
                    'address' => [
                        'name' => 'AND_ANOTHER_NAME',
                        'email' => 'AND_ANOTHER_EMAIL',
                    ],
                ],
            ],
        ]);

        $promise = $sparky->transmissions->get();

        try {
            $promise->wait();
        } catch (\Throwable $t) {
            echo $t->getCode()."\n";
            echo $t->getMessage()."\n";
        }

    }
}

Documentation

Detailed documentation on how to access each API method can be found in the documentation of the package that this bundle integrates: Sparkpost API library, (*8)

License

This package is available under the MIT license., (*9)

The Versions

08/02 2018

dev-master

9999999-dev https://github.com/tlamedia

The SparkPostBundle integrates the SparkPost PHP library with Symfony, allowing you to interact with the Sparkpost API in your Symfony projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Torben Lundsgaard

bundle symfony sparkpost

08/02 2018

0.1.0

0.1.0.0 https://github.com/tlamedia

Symfony SparkPostBundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Torben Lundsgaard

bundle symfony sparkpost