2018-10-11 15:00:23 -07:00
< ? php
2018-12-28 10:35:52 -08:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2018-10-11 15:00:23 -07:00
// SPDX-License-Identifier: Apache-2.0
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
/*
2018-10-16 20:34:57 -07:00
* 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
2018-10-11 15:00:23 -07:00
*
*/
2019-02-05 21:31:08 -08:00
// snippet-start:[ses.php.create_template.complete]
// snippet-start:[ses.php.create_template.import]
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
require 'vendor/autoload.php' ;
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
use Aws\Exception\AwsException ;
2024-02-05 10:49:20 -07:00
2019-02-05 21:31:08 -08:00
// snippet-end:[ses.php.create_template.import]
2024-02-05 10:49:20 -07:00
2019-02-05 21:31:08 -08:00
//Create a SESClient
// snippet-start:[ses.php.create_template.main]
2019-06-07 20:04:21 +09:00
$SesClient = new Aws\Ses\SesClient ([
2018-10-11 15:00:23 -07:00
'profile' => 'default' ,
'version' => '2010-12-01' ,
'region' => 'us-east-2'
]);
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
$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.' ;
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
try {
$result = $SesClient -> createTemplate ([
'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 " ;
}
2024-02-05 10:49:20 -07:00
2019-02-05 21:31:08 -08:00
// snippet-end:[ses.php.create_template.main]
// snippet-end:[ses.php.create_template.complete]