Skip to content

Commit e034d06

Browse files
committed
MA-946 #time 2h updated defaults, readme documentation, and fixed
formatting in examples
1 parent 68a7e8e commit e034d06

File tree

8 files changed

+77
-88
lines changed

8 files changed

+77
-88
lines changed

README.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To get an API Key, please log in to your SparkPost account and generate one in t
1111
The 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
```
1616
Next, 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+
4429
try {
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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
<?php
22
namespace Examples\Transmisson;
3-
require_once (dirname(__FILE__).'/../bootstrap.php');
3+
require_once (dirname(__FILE__).'/../bootstrap.php');
44

5-
use MessageSystems\SparkPost;
6-
use MessageSystems\Transmission;
5+
use MessageSystems\SparkPost;
6+
use MessageSystems\Transmission;
77

8-
$key = 'YOURAPIKEY';
9-
SparkPost::setConfig(['key'=>$key]);
8+
$key = 'YOURAPIKEY';
9+
SparkPost::setConfig(['key'=>$key]);
10+
11+
try {
12+
$results = Transmission::send([
13+
"returnPath"=>"return@example.com",
14+
"from"=>"From Envelope <from@example.com>",
15+
"html"=>"<p>Hello World!</p>",
16+
"text"=>"Hello World!",
17+
"subject"=>"Example Email",
18+
"recipients"=>[
19+
[
20+
"address"=>[
21+
"email"=>"john.doe@example.com"
22+
]
23+
]
24+
]
25+
]);
26+
echo 'Congrats you can use your SDK!';
1027

11-
try {
12-
$results = Transmission::send([
13-
"returnPath"=>"return@example.com",
14-
"from"=>"From Envelope <from@example.com>",
15-
"html"=>"<p>Hello World!</p>",
16-
"text"=>"Hello World!",
17-
"subject"=>"Example Email",
18-
"recipients"=>[
19-
[
20-
"address"=>[
21-
"email"=>"jordan.nornhold@rackspace.messagesystems.com"
22-
]
23-
]
24-
]
25-
]);
26-
echo 'Congrats you can use your SDK!';
27-
28-
var_dump(Transmission::$structure);
29-
} catch (\Exception $exception) {
30-
echo $exception->getMessage();
31-
}
28+
var_dump(Transmission::$structure);
29+
} catch (\Exception $exception) {
30+
echo $exception->getMessage();
31+
}
3232
?>
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22
namespace Examples\Transmisson;
3-
require_once (dirname(__FILE__).'/../bootstrap.php');
4-
5-
use MessageSystems\SparkPost;
6-
use MessageSystems\Transmission;
7-
8-
$key = 'YOURAPIKEY';
9-
SparkPost::setConfig(['key'=>$key]);
10-
11-
try {
12-
$results = Transmission::all();
13-
echo 'Congrats you can use your SDK!';
14-
} catch (\Exception $exception) {
15-
echo $exception->getMessage();
16-
}
3+
require_once (dirname(__FILE__).'/../bootstrap.php');
4+
5+
use MessageSystems\SparkPost;
6+
use MessageSystems\Transmission;
7+
8+
$key = 'YOURAPIKEY';
9+
SparkPost::setConfig(['key'=>$key]);
10+
11+
try {
12+
$results = Transmission::all();
13+
echo 'Congrats you can use your SDK!';
14+
} catch (\Exception $exception) {
15+
echo $exception->getMessage();
16+
}
1717
?>

examples/transmission/get_transmission.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
namespace Examples\Transmisson;
33
require_once (dirname(__FILE__).'/../bootstrap.php');
4-
use MessageSystems\SparkPost;
5-
use MessageSystems\Transmission;
6-
7-
$key = 'YOURAPIKEY';
8-
SparkPost::setConfig(['key'=>$key]);
4+
use MessageSystems\SparkPost;
5+
use MessageSystems\Transmission;
6+
7+
$key = 'YOURAPIKEY';
8+
SparkPost::setConfig(['key'=>$key]);
99

1010
try {
1111
$results = Transmission::find('Your Transmission Id');

examples/transmission/rfc822.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
namespace Examples\Transmisson;
33
require_once (dirname(__FILE__).'/../bootstrap.php');
4-
use MessageSystems\SparkPost;
5-
use MessageSystems\Transmission;
6-
7-
$key = 'YOURAPIKEY';
8-
SparkPost::setConfig(['key'=>$key]);
4+
use MessageSystems\SparkPost;
5+
use MessageSystems\Transmission;
6+
7+
$key = 'YOURAPIKEY';
8+
SparkPost::setConfig(['key'=>$key]);
99

1010
try {
1111
$results = Transmission::send([

examples/transmission/stored_recipients_inline_content.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<?php
22
namespace Examples\Transmisson;
33
require_once (dirname(__FILE__).'/../bootstrap.php');
4-
use MessageSystems\SparkPost;
5-
use MessageSystems\Transmission;
6-
7-
$key = 'YOURAPIKEY';
8-
SparkPost::setConfig(['key'=>$key]);
9-
4+
use MessageSystems\SparkPost;
5+
use MessageSystems\Transmission;
106

7+
$key = 'YOURAPIKEY';
8+
SparkPost::setConfig(['key'=>$key]);
119

1210
try {
1311

examples/transmission/stored_template_send.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
namespace Examples\Transmisson;
33
require_once (dirname(__FILE__).'/../bootstrap.php');
4-
use MessageSystems\SparkPost;
5-
use MessageSystems\Transmission;
6-
7-
$key = 'YOURAPIKEY';
8-
SparkPost::setConfig(['key'=>$key]);
4+
use MessageSystems\SparkPost;
5+
use MessageSystems\Transmission;
6+
7+
$key = 'YOURAPIKEY';
8+
SparkPost::setConfig(['key'=>$key]);
99

1010
try {
1111
$results = Transmission::send([

lib/MessageSystems/Transmission.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ class Transmission {
3838
'email_rfc822'=>null
3939
],
4040
'options'=>[
41-
'open_tracking'=>null,
42-
'click_tracking'=>null
43-
]
41+
'open_tracking'=>true,
42+
'click_tracking'=>true
43+
],
44+
'use_draft_template'=>false
4445
];
4546

4647
/**

0 commit comments

Comments
 (0)