diff options
Diffstat (limited to 'examples/transmission/rfc822.php')
-rw-r--r-- | examples/transmission/rfc822.php | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/examples/transmission/rfc822.php b/examples/transmission/rfc822.php index 8163693..1054c57 100644 --- a/examples/transmission/rfc822.php +++ b/examples/transmission/rfc822.php @@ -3,27 +3,29 @@ namespace Examples\Transmisson; require_once (dirname(__FILE__).'/../bootstrap.php'); //pull in API key config -$configFile = file_get_contents(dirname(__FILE__) . "/../example-config.json"); +$configFile = file_get_contents(dirname(__FILE__) . '/../example-config.json'); $config = json_decode($configFile, true); use SparkPost\SparkPost; -use SparkPost\Transmission; +use GuzzleHttp\Client; +use Ivory\HttpAdapter\Guzzle6HttpAdapter; -SparkPost::setConfig(array('key'=>$config['api-key'])); +$httpAdapter = new Guzzle6HttpAdapter(new Client()); +$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]); try { - $results = Transmission::send(array( - 'recipients'=>array( - array( - 'address'=>array( - 'email'=>'john.doe@sample.com' - ) - ) - ), - 'rfc822'=>"Content-Type: text/plain\nFrom: From Envelope <from@example.com>\nSubject: Example Email\n\nHello World" - )); - echo 'Congrats you can use your SDK!'; + $results = $sparky->transmission->send([ + 'recipients'=>[ + [ + 'address'=>[ + 'email'=>'john.doe@example.com' + ] + ] + ], + 'rfc822'=>'Content-Type: text/plain\nFrom: From Envelope <from@sparkpostbox.com>\nSubject: Example Email\n\nHello World' + ]); + echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { - echo $exception->getMessage(); + echo $exception->getMessage(); } ?> |