@@ -11,7 +11,7 @@ To get an API Key, please log in to your SparkPost account and generate one in t
1111The recommended way to install the SparkPost PHP SDK is through composer.
1212```
1313# Install Composer
14- curl -sS https:// getcomposer.org/installer | php
14+ curl -sS https://getcomposer.org/installer | php
1515```
1616Next, run the Composer command to install the SparkPost PHP SDK:
1717```
@@ -24,25 +24,19 @@ require 'vendor/autoload.php';
2424
2525## Getting Started: Your First Mailing
2626```
27- $sparkpost = new SparkPost(["key"=>"YOUR API KEY"]);
28-
29- $transmission = $sparkpost->transmission();
30-
31- // Add some template data to your email
32- $transmission->setCampaign('first-mailing')->
33- setReturnPath('bounces@sparkpost.com')->
34- setFrom('you@your-company.com')->
35- setSubject('First SDK Mailing')->
36- setHTMLContent('<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>')->
37- setTextContent('Congratulations, {{name}}!! You just sent your very first mailing!')->
38- setSubstitutionData(['name'=>'YOUR FIRST NAME']);
39-
40- // Pick someone to receive your email
41- $transmission->addRecipient(['address'=>['name'=>'YOUR FULL NAME', 'email'=>'YOUR EMAIL ADDRESS' ]]);
42-
43- // Send it off into the world!
27+ SparkPost::setConfig(["key"=>"YOUR API KEY"]);
28+
4429try {
45- $response = $transmission->send();
30+ // Build your email and send it!
31+ Transmission::send(['campaign'=>'first-mailing',
32+ 'from'=>'you@your-company.com',
33+ 'subject'=>'First SDK Mailing',
34+ 'html'=>'<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>',
35+ 'text'=>'Congratulations, {{name}}!! You just sent your very first mailing!',
36+ 'substitutionData'=>['name'=>'YOUR FIRST NAME'],
37+ 'recipients'=>[['address'=>['name'=>'YOUR FULL NAME', 'email'=>'YOUR EMAIL ADDRESS' ]]]
38+ ]);
39+
4640 echo 'Woohoo! You just sent your first mailing!';
4741} catch (Exception $err) {
4842 echo 'Whoops! Something went wrong';
@@ -59,16 +53,12 @@ try {
5953### General
6054* You _ must_ provide at least an API key when instantiating the SparkPost Library - ` [ 'key'=>'184ac5480cfdd2bb2859e4476d2e5b1d2bad079bf' ] `
6155* The SDK's features are namespaced under the various SparkPost API names.
62- * There are two ways to provide values to each namespace of the SDK:
63- - On instantiation, you pass in a well-formed object (See examples).
64- - You use the helper methods to incrementally create a well-formed object. These helper methods are chainable (See examples).
6556
6657### Transmissions
6758* If you specify a stored recipient list and inline recipients in a Transmission, whichever was provided last will be used.
68- * If you call addRecipient and then useRecipientList, the latter will overwrite the former.
6959* If you specify HTML and/or Plain Text content and then provide RFC-822 encoded content, you will receive an error.
7060 * RFC-822 content is not valid with any other content type.
71- * If you specify a stored template and also provide inline content via setHTMLContent or setTextContent , you will receive an error.
61+ * If you specify a stored template and also provide inline content via ` html ` or ` text ` , you will receive an error.
7262* By default, open and click tracking are enabled for a transmission.
7363* By default, a transmission will use the published version of a stored template.
7464
0 commit comments