Skip to content

Commit f531e0d

Browse files
committed
Update docs to use extended from format
1 parent e094505 commit f531e0d

File tree

5 files changed

+133
-114
lines changed

5 files changed

+133
-114
lines changed

README.md

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,29 @@ $httpAdapter = new Guzzle6HttpAdapter(new Client());
6868
$sparky = new SparkPost($httpAdapter, ['key'=>'YOUR API KEY']);
6969

7070
try {
71-
// Build your email and send it!
72-
$results = $sparky->transmission->send([
73-
'from'=>'From Envelope <from@sparkpostbox.com>',
74-
'html'=>'<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>',
75-
'text'=>'Congratulations, {{name}}!! You just sent your very first mailing!',
76-
'substitutionData'=>['name'=>'YOUR FIRST NAME'],
77-
'subject'=>'First Mailing From PHP',
78-
'recipients'=>[
79-
[
80-
'address'=>[
81-
'name'=>'YOUR FULL NAME',
82-
'email'=>'YOUR EMAIL ADDRESS'
71+
// Build your email and send it!
72+
$results = $sparky->transmission->send([
73+
'from'=>[
74+
'name' => 'From Envelope',
75+
'email' => 'from@sparkpostbox.com>'
76+
],
77+
'html'=>'<html><body><h1>Congratulations, {{name}}!</h1><p>You just sent your very first mailing!</p></body></html>',
78+
'text'=>'Congratulations, {{name}}!! You just sent your very first mailing!',
79+
'substitutionData'=>['name'=>'YOUR FIRST NAME'],
80+
'subject'=>'First Mailing From PHP',
81+
'recipients'=>[
82+
[
83+
'address'=>[
84+
'name'=>'YOUR FULL NAME',
85+
'email'=>'YOUR EMAIL ADDRESS'
86+
]
87+
]
8388
]
84-
]
85-
]
86-
]);
87-
echo 'Woohoo! You just sent your first mailing!';
89+
]);
90+
echo 'Woohoo! You just sent your first mailing!';
8891
} catch (\Exception $err) {
89-
echo 'Whoops! Something went wrong';
90-
var_dump($err);
92+
echo 'Whoops! Something went wrong';
93+
var_dump($err);
9194
}
9295
```
9396

@@ -98,25 +101,29 @@ try {
98101

99102
## Field Descriptions
100103
### Transmissions
101-
| Field Name | Required? | Description | Data Type |
102-
| ------------ | ----------- | ------------- | ----------- |
103-
| description | no | Field for describing what this transmission is for the user | String |
104-
| campaign | no | Field for assigning a given transmission to a specific campaign, which is a logical container for similar transmissions | String |
105-
| metadata | no | Field for adding arbitrary key/value pairs which will be included in open/click tracking | Object (Simple) |
106-
| substitutionData | no | Field for adding transmission level substitution data, which can be used in a variety of fields and in content | Object (Complex) |
107-
| trackOpens | no | Field for enabling/disabling transmission level open tracking (default: true) | Boolean |
108-
| trackClicks | no | Field for enabling/disabling transmission level click tracking (default: true) | Boolean |
109-
| useDraftTemplate | no | Field for allowing the sending of a transmission using a draft of a stored template (default: false) | Boolean |
110-
| replyTo | no | Field for specifying the email address that should be used when a recipient hits the reply button | String |
111-
| subject | yes | Field for setting the subject line of a given transmission | String |
112-
| from | yes** | Field for setting the from line of a given transmission | String or Object |
113-
| html | yes** | Field for setting the HTML content of a given transmission | String |
114-
| text | yes** | Field for setting the Plain Text content of a given transmission | String |
115-
| rfc822 | no** | Field for setting the RFC-822 encoded content of a given transmission | String |
116-
| template | no** | Field for specifying the Template ID of a stored template to be used when sending a given transmission | String |
117-
| customHeaders | no | Field for specifying additional headers to be applied to a given transmission (other than Subject, From, To, and Reply-To) | Object (Simple) |
118-
| recipients | yes** | Field for specifying who a given transmission should be sent to | Array of Objects |
119-
| recipientList | no** | Field for specifying a stored recipient list ID to be used for a given transmission | String |
104+
| Field Name | Required? | Description | Data Type |
105+
| ------------ | ----------- | ------------- | ----------- |
106+
| attachments | no | Field for attaching files - see Attachment Attributes in the [Transmssions API docs](https://developers.sparkpost.com/api/#/reference/transmissions) | Array of Objects |
107+
| campaign | no | Field for assigning a given transmission to a specific campaign, which is a logical container for similar transmissions | String |
108+
| customHeaders | no | Field for specifying additional headers to be applied to a given transmission (other than Subject, From, To, and Reply-To) | Object (Simple) |
109+
| description | no | Field for describing what this transmission is for the user | String |
110+
| from | yes** | Field for setting the from line of a given transmission | Object |
111+
| html | yes** | Field for setting the HTML content of a given transmission | String |
112+
| inlineCss | no | Field for enabling/disabling CSS inlining | Boolean |
113+
| inlineImages | no | Field for providing inline images - see Inline Image Attributes in the [Transmssions API docs](https://developers.sparkpost.com/api/#/reference/transmissions) | Array of Objects |
114+
| metadata | no | Field for adding arbitrary key/value pairs which will be included in open/click tracking | Object (Simple) |
115+
| recipientList | no** | Field for specifying a stored recipient list ID to be used for a given transmission | String |
116+
| recipients | yes** | Field for specifying who a given transmission should be sent to | Array of Objects |
117+
| replyTo | no | Field for specifying the email address that should be used when a recipient hits the reply button | String |
118+
| rfc822 | no** | Field for setting the RFC-822 encoded content of a given transmission | String |
119+
| subject | yes | Field for setting the subject line of a given transmission | String |
120+
| substitutionData | no | Field for adding transmission level substitution data, which can be used in a variety of fields and in content | Object (Complex) |
121+
| template | no** | Field for specifying the Template ID of a stored template to be used when sending a given transmission | String |
122+
| text | yes** | Field for setting the Plain Text content of a given transmission | String |
123+
| trackClicks | no | Field for enabling/disabling transmission level click tracking (default: true) | Boolean |
124+
| trackOpens | no | Field for enabling/disabling transmission level open tracking (default: true) | Boolean |
125+
| transactional | no | Field for marking email as transactional (default: false) | Boolean |
126+
| useDraftTemplate | no | Field for allowing the sending of a transmission using a draft of a stored template (default: false) | Boolean |
120127

121128
** - If using inline content then html or text are required. If using RFC-822 Inline Content, then rfc822 is required. If using a stored recipient list, then recipientList is required. If using a stored template, then template is required but from is not as the values from the template will be used.
122129

examples/transmission/send_transmission_all_fields.php

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,51 @@
1616
$data = file_get_contents('/path/to/test.csv');
1717

1818
try{
19-
$results = $sparky->transmission->send([
20-
'campaign'=>'my-campaign',
21-
'metadata'=>[
22-
'sample_campaign'=>true,
23-
'type'=>'these are custom fields'
24-
],
25-
'substitutionData'=>[
26-
'name'=>'Test Name'
27-
],
28-
'description'=>'my description',
29-
'replyTo'=>'reply@test.com',
30-
'customHeaders'=>[
31-
'X-Custom-Header'=>'Sample Custom Header'
32-
],
33-
'trackOpens'=>false,
34-
'trackClicks'=>false,
35-
'sandbox'=>false,
36-
'inlineCss'=>true,
37-
'transactional'=>true,
38-
'startTime'=>'2016-03-17T08:00:00-04:00',
39-
'from'=>'From Envelope <from@sparkpostbox.com>',
40-
'html'=>'<p>Hello World! Your name is: {{name}}</p>',
41-
'text'=>'Hello World!',
42-
'subject'=>'Example Email: {{name}}',
43-
'recipients'=>[
44-
[
45-
'address'=>[
46-
'email'=>'john.doe@example.com'
19+
$results = $sparky->transmission->send([
20+
'campaign'=>'my-campaign',
21+
'metadata'=>[
22+
'sample_campaign'=>true,
23+
'type'=>'these are custom fields'
24+
],
25+
'substitutionData'=>[
26+
'name'=>'Test Name'
27+
],
28+
'description'=>'my description',
29+
'replyTo'=>'reply@test.com',
30+
'customHeaders'=>[
31+
'X-Custom-Header'=>'Sample Custom Header'
32+
],
33+
'trackOpens'=>false,
34+
'trackClicks'=>false,
35+
'sandbox'=>false,
36+
'inlineCss'=>true,
37+
'transactional'=>true,
38+
'startTime'=>'2016-03-17T08:00:00-04:00',
39+
'from'=>[
40+
'name' => 'From Envelope',
41+
'email' => 'from@sparkpostbox.com>'
42+
],
43+
'html'=>'<p>Hello World! Your name is: {{name}}</p>',
44+
'text'=>'Hello World!',
45+
'subject'=>'Example Email: {{name}}',
46+
'recipients'=>[
47+
[
48+
'address'=>[
49+
'email'=>'john.doe@example.com'
50+
]
51+
]
52+
],
53+
'attachments'=>[
54+
[
55+
'type'=>'text/csv',
56+
'name'=>'testing.csv',
57+
'data'=>base64_encode($data)
58+
]
4759
]
48-
]
49-
],
50-
'attachments'=>[
51-
[
52-
'type'=>'text/csv',
53-
'name'=>'testing.csv',
54-
'data'=>base64_encode($data)
55-
]
56-
]
57-
]);
60+
]);
5861

59-
echo 'Congrats you can use your SDK!';
62+
echo 'Congrats you can use your SDK!';
6063
} catch (\Exception $exception) {
61-
echo $exception->getMessage();
64+
echo $exception->getMessage();
6265
}
6366
?>

examples/transmission/simple_send.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@
1414
$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]);
1515

1616
try {
17-
$results = $sparky->transmission->send([
18-
'from'=>'From Envelope <from@sparkpostbox.com>',
19-
'html'=>'<p>Hello World!</p>',
20-
'text'=>'Hello World!',
21-
'subject'=>'Example Email',
22-
'recipients'=>[
23-
[
24-
'address'=>[
25-
'email'=>'john.doe@example.com'
17+
$results = $sparky->transmission->send([
18+
'from'=>[
19+
'name' => 'From Envelope',
20+
'email' => 'from@sparkpostbox.com>'
21+
],
22+
'html'=>'<p>Hello World!</p>',
23+
'text'=>'Hello World!',
24+
'subject'=>'Example Email',
25+
'recipients'=>[
26+
[
27+
'address'=>[
28+
'email'=>'john.doe@example.com'
29+
]
30+
]
2631
]
27-
]
28-
]
29-
]);
30-
echo 'Congrats you can use your SDK!';
32+
]);
33+
echo 'Congrats you can use your SDK!';
3134
} catch (\Exception $exception) {
32-
echo $exception->getMessage();
35+
echo $exception->getMessage();
3336
}
3437
?>

examples/transmission/stored_recipients_inline_content.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@
1515

1616
try {
1717

18-
$results = $sparky->transmission->send([
19-
'campaign'=>'my-campaign',
20-
'from'=>'From Envelope <from@sparkpostbox.com>',
21-
'html'=>'<p>Hello World! Your name is: {{name}}</p>',
22-
'text'=>'Hello World!',
23-
'subject'=>'Example Email: {{name}}',
24-
'recipientList'=>'Example List'
25-
]);
18+
$results = $sparky->transmission->send([
19+
'campaign'=>'my-campaign',
20+
'from'=>[
21+
'name' => 'From Envelope',
22+
'email' => 'from@sparkpostbox.com>'
23+
],
24+
'html'=>'<p>Hello World! Your name is: {{name}}</p>',
25+
'text'=>'Hello World!',
26+
'subject'=>'Example Email: {{name}}',
27+
'recipientList'=>'Example List'
28+
]);
2629

27-
echo 'Congrats you can use your SDK!';
30+
echo 'Congrats you can use your SDK!';
2831
} catch (\Exception $exception) {
29-
echo $exception->getMessage();
32+
echo $exception->getMessage();
3033
}
3134
?>

examples/transmission/stored_template_send.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@
1414
$sparky = new SparkPost($httpAdapter, ['key'=>$config['api-key']]);
1515

1616
try {
17-
$results = $sparky->transmission->send([
18-
'from'=>'From Envelope <from@sparkpostbox.com>',
19-
'recipients'=>[
20-
[
21-
'address'=>[
22-
'email'=>'john.doe@example.com'
23-
]
24-
]
25-
],
26-
'template'=>'my-first-email'
27-
]);
28-
echo 'Congrats you can use your SDK!';
17+
$results = $sparky->transmission->send([
18+
'from'=>[
19+
'name' => 'From Envelope',
20+
'email' => 'from@sparkpostbox.com>'
21+
],
22+
'recipients'=>[
23+
[
24+
'address'=>[
25+
'email'=>'john.doe@example.com'
26+
]
27+
]
28+
],
29+
'template'=>'my-first-email'
30+
]);
31+
echo 'Congrats you can use your SDK!';
2932
} catch (\Exception $exception) {
30-
echo $exception->getMessage();
33+
echo $exception->getMessage();
3134
}
3235
?>

0 commit comments

Comments
 (0)