Debian Codegraph @

docs/source/guide/ses-rules.rst

raw
1 .. Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
3 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0
4 International License (the "License"). You may not use this file except in compliance with the
5 License. A copy of the License is located at http://creativecommons.org/licenses/by-nc-sa/4.0/.
6
7 This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
8 either express or implied. See the License for the specific language governing permissions and
9 limitations under the License.
10
11 .. _aws-boto3-ses-rules:
12
13
14 ####################################################
15 Creating and managing email rules with the SES API
16 ####################################################
17
18 .. meta::
19 :description: Use the Amazon SES API to manage email rules.
20 :keywords: SES Python
21
22 In addition to sending emails, you can also receive email with Amazon Simple
23 Email Service (SES). Receipt rules enable you to specify what SES does with
24 email it receives for the email addresses or domains you own. A rule can send
25 email to other AWS services including but not limited to Amazon S3, Amazon
26 SNS, or AWS Lambda.
27
28 For more information, see `Managing Receipt Rule Sets for Amazon SES Email
29 Receiving <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-managing-receipt-rule-sets.html>`_
30 and `Managing Receipt Rules for Amazon SES Email
31 Receiving <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-managing-receipt-rules.html>`_.
32
33 The following examples show how to:
34
35 * Create a receipt rule set using `create_receipt_rule_set() <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html#SES.Client.create_receipt_rule_set>`_.
36 * Create a receipt rule using `create_receipt_rule() <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html#SES.Client.create_receipt_rule>`_.
37 * Remove a receipt rule using `delete_receipt_rule() <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html#SES.Client.delete_receipt_rule>`_.
38 * Remove a receipt rule set using `delete_receipt_rule_set() <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html#SES.Client.delete_receipt_rule_set>`_.
39
40
41 Prerequisite tasks
42 ==================
43
44 To set up and run this example, you must first complete these tasks:
45
46 * Configure your AWS credentials, as described in :doc:`quickstart`.
47
48
49 Create a receipt rule set
50 ==========================
51
52 A receipt rule set contains a collection of receipt rules. You must have at
53 least one receipt rule set associated with your account before you can create
54 a receipt rule. To create a receipt rule set, provide a unique RuleSetName and
55 use the
56 `CreateReceiptRuleSet <https://docs.aws.amazon.com/ses/latest/APIReference/API_CreateReceiptRuleSet.html>`_
57 operation.
58
59 Example
60 -------
61
62 .. code-block:: python
63
64 import boto3
65
66 # Create SES client
67 ses = boto3.client('ses')
68
69 response = ses.create_receipt_rule_set(
70 RuleSetName = 'RULE_SET_NAME',
71 )
72
73 print(response)
74
75
76 Create a receipt rule
77 =====================
78
79 Control your incoming email by adding a receipt rule to an existing
80 receipt rule set. This example shows you how to create a receipt rule that
81 sends incoming messages to an Amazon S3 bucket, but you can also send
82 messages to Amazon SNS and AWS Lambda. To create a receipt rule, provide a
83 rule and the RuleSetName to the
84 `CreateReceiptRule <https://docs.aws.amazon.com/ses/latest/APIReference/API_CreateReceiptRule.html>`_
85 operation.
86
87 Example
88 -------
89
90 .. code-block:: python
91
92 import boto3
93
94 # Create SES client
95 ses = boto3.client('ses')
96
97 response = ses.create_receipt_rule(
98 RuleSetName = 'RULE_SET_NAME',
99 Rule = {
100 'Name' : 'RULE_NAME',
101 'Enabled' : True,
102 'TlsPolicy' : 'Optional',
103 'Recipients': [
104 'EMAIL_ADDRESS',
105 ],
106 'Actions' : [
107 {
108 'S3Action' : {
109 'BucketName' : 'amzn-s3-demo-bucket',
110 'ObjectKeyPrefix': 'SES_email'
111 }
112 }
113 ],
114 }
115 )
116
117 print(response)
118
119
120 Delete a receipt rule set
121 ==========================
122
123 Remove a specified receipt rule set that isn't currently disabled. This also
124 deletes all of the receipt rules it contains. To delete a receipt rule set,
125 provide the RuleSetName to the
126 `DeleteReceiptRuleSet <https://docs.aws.amazon.com/ses/latest/APIReference/API_DeleteReceiptRuleSet.html>`_
127 operation.
128
129 Example
130 -------
131
132 .. code-block:: python
133
134 import boto3
135
136 # Create SES client
137 ses = boto3.client('ses')
138
139 response = ses.delete_receipt_rule(
140 RuleName='RULE_NAME',
141 RuleSetName='RULE_SET_NAME'
142 )
143
144 print(response)
145
146
147 Delete a receipt rule
148 =====================
149
150 To delete a specified receipt rule, provide the RuleName and RuleSetName to the
151 `DeleteReceiptRule <https://docs.aws.amazon.com/ses/latest/APIReference/API_DeleteReceiptRule.html>`_
152 operation.
153
154 Example
155 -------
156
157 .. code-block:: python
158
159 import boto3
160
161 # Create SES client
162 ses = boto3.client('ses')
163
164 response = ses.delete_receipt_rule_set(
165 RuleSetName = 'RULE_SET_NAME'
166 )
167
168 print(response)