Debian Codegraph @

docs/source/guide/ses-filters.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-filters:
12
13
14 ###################################
15 Managing email filters with SES API
16 ###################################
17
18 .. meta::
19 :description: Use the Amazon SES API to manage email filters.
20 :keywords: SES Python
21
22 In addition to sending emails, you can also receive email with Amazon Simple
23 Email Service (SES). An IP address filter enables you to optionally specify
24 whether to accept or reject mail that originates from an IP address or range
25 of IP addresses. For more information, see `Managing IP Address Filters for
26 Amazon SES Email
27 Receiving <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-managing-ip-filters.html>`__.
28
29 The following examples show how to:
30
31 * Create an email filter using
32 `create_receipt_filter() <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html#SES.Client.create_receipt_filter>`__.
33 * List all email filters using
34 `list_receipt_filters() <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html#SES.Client.list_receipt_filters>`__.
35 * Remove an email filter using
36 `delete_receipt_filter() <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses.html#SES.Client.delete_receipt_filter>`__.
37
38
39 Prerequisite tasks
40 ==================
41
42 To set up and run this example, you must first complete these tasks:
43
44 * Configure your AWS credentials, as described in :doc:`quickstart`.
45
46
47 Create an email filter
48 ======================
49
50 To allow or block emails from a specific IP address, use the
51 `CreateReceiptFilter <https://docs.aws.amazon.com/ses/latest/APIReference/API_CreateReceiptFilter.html>`__
52 operation. Provide the IP address or range of addresses and a unique name to
53 identify this filter.
54
55 Example
56 -------
57
58 .. code-block:: python
59
60 import boto3
61
62 # Create SES client
63 ses = boto3.client('ses')
64
65 # Create receipt filter
66 response = ses.create_receipt_filter(
67 Filter = {
68 'NAME' : 'NAME',
69 'IpFilter' : {
70 'Cidr' : 'IP_ADDRESS_OR_RANGE',
71 'Policy' : 'Allow'
72 }
73 }
74 )
75
76 print(response)
77
78
79 List all email filters
80 ======================
81
82 To list the IP address filters associated with your AWS account in the current
83 AWS Region, use the
84 `ListReceiptFilters <https://docs.aws.amazon.com/ses/latest/APIReference/API_ListReceiptFilters.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.list_receipt_filters()
98
99 print(response)
100
101
102 Delete an email filter
103 ======================
104
105 To remove an existing filter for a specific IP address use the
106 `DeleteReceiptFilter <https://docs.aws.amazon.com/ses/latest/APIReference/API_DeleteReceiptFilter.html>`__
107 operation. Provide the unique filter name to identify the receipt filter to
108 delete.
109
110 If you need to change the range of addresses that are filtered, you can delete
111 a receipt filter and create a new one.
112
113 Example
114 -------
115
116 .. code-block:: python
117
118 import boto3
119
120 # Create SES client
121 ses = boto3.client('ses')
122
123 response = ses.delete_receipt_filter(
124 FilterName = 'NAME'
125 )
126
127 print(response)