PHP code example of dallasmakerspace / cakephp-sparkpost-plugin

1. Go to this page and download the library: Download dallasmakerspace/cakephp-sparkpost-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dallasmakerspace / cakephp-sparkpost-plugin example snippets


Plugin::load('SparkPost');

'SparkPost' => [
    'Api' => [
        'key' => 'YOUR_SPARKPOST_API_KEY'
    ]
]

// Configure email transport
Email::configTransport('sparkpost', [
    'className' => 'SparkPost.SparkPost',
    'apiKey' => Configure::read('SparkPost.Api.key')
]);

// Create email message
$email = new Email();
$email->transport('sparkpost');

$email->from(['FROM_ADDRESS' => 'FROM_NAME']);
$email->to(['TO_ADDRESS' => 'TO_NAME']);
$email->subject('SUBJECT');
$email->send('BODY');