Skip to content

Commit d2911c6

Browse files
Atanas Damyanlievbshaffer
authored andcommitted
updating Mailjet code samples for Send API v3.1 (GoogleCloudPlatform#432)
1 parent 42f0f7c commit d2911c6

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

appengine/flexible/mailjet/app.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,34 @@
4040
/** @var Mailjet\Client $mailjet */
4141
$mailjet = $app['mailjet'];
4242
$recipient = $request->get('recipient');
43-
4443
# [START send_email]
4544
$body = [
46-
'FromEmail' => "[email protected]",
47-
'FromName' => "Testing Mailjet",
48-
'Subject' => "Your email flight plan!",
49-
'Text-part' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
50-
'Html-part' => "

Dear passenger, welcome to Mailjet!


May the delivery force be with you!
"
,
51-
'Recipients' => [
45+
'Messages' => [
5246
[
53-
'Email' => $recipient,
47+
'From' => [
48+
'Email' => "[email protected]",
49+
'Name' => "Mailjet Pilot"
50+
],
51+
'To' => [
52+
[
53+
'Email' => $recipient
54+
]
55+
],
56+
'Subject' => "Your email flight plan!",
57+
'TextPart' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
58+
'HTMLPart' => "

Dear passenger, welcome to Mailjet!


May the delivery force be with you!
"
5459
]
5560
]
5661
];
57-
5862
// trigger the API call
59-
$response = $mailjet->post(Mailjet\Resources::$Email, ['body' => $body]);
63+
$response = $mailjet->post(Mailjet\Resources::$Email, ['body' => $body], ['version' => 'v3.1']);
6064
if ($response->success()) {
6165
// if the call succed, data will go here
6266
return sprintf(
6367
'
%s
'
,
6468
json_encode($response->getData(), JSON_PRETTY_PRINT)
6569
);
6670
}
67-
6871
return 'Error: ' . print_r($response->getStatus(), true);
6972
# [END send_email]
7073
});

appengine/flexible/mailjet/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"require": {
33
"silex/silex": "^1.3",
4-
"mailjet/mailjet-apiv3-php": "^1.1",
4+
"mailjet/mailjet-apiv3-php": "^1.2",
55
"guzzlehttp/guzzle": "~6.1.0"
66
},
77
"require-dev": {

appengine/standard/mailjet/app.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,34 @@
4040
/** @var Mailjet\Client $mailjet */
4141
$mailjet = $app['mailjet'];
4242
$recipient = $request->get('recipient');
43-
4443
# [START send_email]
4544
$body = [
46-
'FromEmail' => "[email protected]",
47-
'FromName' => "Testing Mailjet",
48-
'Subject' => "Your email flight plan!",
49-
'Text-part' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
50-
'Html-part' => "

Dear passenger, welcome to Mailjet!


May the delivery force be with you!
"
,
51-
'Recipients' => [
45+
'Messages' => [
5246
[
53-
'Email' => $recipient,
47+
'From' => [
48+
'Email' => "[email protected]",
49+
'Name' => "Mailjet Pilot"
50+
],
51+
'To' => [
52+
[
53+
'Email' => $recipient
54+
]
55+
],
56+
'Subject' => "Your email flight plan!",
57+
'TextPart' => "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
58+
'HTMLPart' => "

Dear passenger, welcome to Mailjet!


May the delivery force be with you!
"
5459
]
5560
]
5661
];
57-
5862
// trigger the API call
59-
$response = $mailjet->post(Mailjet\Resources::$Email, ['body' => $body]);
63+
$response = $mailjet->post(Mailjet\Resources::$Email, ['body' => $body], ['version' => 'v3.1']);
6064
if ($response->success()) {
6165
// if the call succed, data will go here
6266
return sprintf(
6367
'
%s
'
,
6468
json_encode($response->getData(), JSON_PRETTY_PRINT)
6569
);
6670
}
67-
6871
return 'Error: ' . print_r($response->getStatus(), true);
6972
# [END send_email]
7073
});

appengine/standard/mailjet/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"require": {
33
"silex/silex": "^1.3",
4-
"mailjet/mailjet-apiv3-php": "^1.1",
4+
"mailjet/mailjet-apiv3-php": "^1.2",
55
"guzzlehttp/guzzle": "~6.1.0"
66
},
77
"require-dev": {

0 commit comments

Comments
 (0)