AWS Code Sample

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.


Create_Rule.php demonstrates how to control your incoming email by adding a receipt rule to an existing receipt rule set. This example shows you how to create a receipt rule that sends incoming messages to an Amazon S3 bucket, but you can also send messages to Amazon SNS, and AWS Lambda.

<?php /** * Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. * * This file is licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. A copy of * the License is located at * * * * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * ABOUT THIS PHP SAMPLE => This sample is part of the SDK for PHP Developer Guide topic at * * */ require 'vendor/autoload.php'; use Aws\Ses\SesClient; use Aws\Exception\AwsException; //Create a SESClient $SesClient = new Aws\Ses\SesClient([ 'profile' => 'default', 'version' => '2010-12-01', 'region' => 'us-east-2' ]); $rule_name = 'Rule_Name'; $rule_set_name = 'Rule_Set_Name'; $s3_bucket = 'Bucket_Name'; try { $result = $SesClient->createReceiptRule([ 'Rule' => [ 'Actions' => [ [ 'S3Action' => [ 'BucketName' => $s3_bucket, ], ], ], 'Name' => $rule_name, 'ScanEnabled' => true, 'TlsPolicy' => 'Optional', 'Recipients' => ['<string>', ...] ], 'RuleSetName' => $rule_set_name, ]); var_dump($result); } catch (AwsException $e) { // output error message if fails echo $e->getMessage(); echo "\n"; }

Sample Details

Service: ses

Last tested: 2018-09-20

Author: jschwarzwalder (AWS)

Type: full-example

On this page: