forked from awsdocs/aws-doc-sdk-examples
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate_Template.php
More file actions
52 lines (44 loc) · 1.57 KB
/
Update_Template.php
File metadata and controls
52 lines (44 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/*
* ABOUT THIS PHP SAMPLE => This sample is part of the SDK for PHP Developer Guide topic at
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/ses-template.html
*
*/
// snippet-start:[ses.php.update_template.complete]
// snippet-start:[ses.php.update_template.import]
require 'vendor/autoload.php';
use Aws\Exception\AwsException;
// snippet-end:[ses.php.update_template.import]
//Create a SESClient
// snippet-start:[ses.php.update_template.main]
$SesClient = new Aws\Ses\SesClient([
'profile' => 'default',
'version' => '2010-12-01',
'region' => 'us-east-2'
]);
$name = 'Template_Name';
$html_body = '<h1>AWS Amazon Simple Email Service Test Email</h1>' .
'<p>This email was sent with <a href="https://aws.amazon.com/ses/">' .
'Amazon SES</a> using the <a href="https://aws.amazon.com/sdk-for-php/">' .
'AWS SDK for PHP</a>.</p>';
$subject = 'Amazon SES test (AWS SDK for PHP)';
$plaintext_body = 'This email was send with Amazon SES using the AWS SDK for PHP.';
try {
$result = $SesClient->updateTemplate([
'Template' => [
'HtmlPart' => $html_body,
'SubjectPart' => $subject,
'TemplateName' => $name,
'TextPart' => $plaintext_body,
],
]);
var_dump($result);
} catch (AwsException $e) {
// output error message if fails
echo $e->getMessage();
echo "\n";
}
// snippet-end:[ses.php.update_template.main]
// snippet-end:[ses.php.update_template.complete]