Delete an Amazon SES receipt filter using an AWS SDK - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Delete an Amazon SES receipt filter using an AWS SDK

The following code examples show how to delete an Amazon SES receipt filter.

C++
SDK for C++
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

//! Delete an Amazon Simple Email Service (Amazon SES) receipt filter. /*! \param receiptFilterName: The name for the receipt filter. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteReceiptFilter(const Aws::String &receiptFilterName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteReceiptFilterRequest deleteReceiptFilterRequest; deleteReceiptFilterRequest.SetFilterName(receiptFilterName); Aws::SES::Model::DeleteReceiptFilterOutcome outcome = sesClient.DeleteReceiptFilter( deleteReceiptFilterRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted receipt filter." << std::endl; } else { std::cerr << "Error deleting receipt filter. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
JavaScript
SDK for JavaScript (v3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

import { DeleteReceiptFilterCommand } from "@aws-sdk/client-ses"; import { sesClient } from "./libs/sesClient.js"; import { getUniqueName } from "@aws-doc-sdk-examples/lib/utils/util-string.js"; const RECEIPT_FILTER_NAME = getUniqueName("ReceiptFilterName"); const createDeleteReceiptFilterCommand = (filterName) => { return new DeleteReceiptFilterCommand({ FilterName: filterName }); }; const run = async () => { const deleteReceiptFilterCommand = createDeleteReceiptFilterCommand(RECEIPT_FILTER_NAME); try { return await sesClient.send(deleteReceiptFilterCommand); } catch (err) { console.log("Error deleting receipt filter.", err); return err; } };
Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

class SesReceiptHandler: """Encapsulates Amazon SES receipt handling functions.""" def __init__(self, ses_client, s3_resource): """ :param ses_client: A Boto3 Amazon SES client. :param s3_resource: A Boto3 Amazon S3 resource. """ self.ses_client = ses_client self.s3_resource = s3_resource def delete_receipt_filter(self, filter_name): """ Deletes a receipt filter. :param filter_name: The name of the filter to delete. """ try: self.ses_client.delete_receipt_filter(FilterName=filter_name) logger.info("Deleted receipt filter %s.", filter_name) except ClientError: logger.exception("Couldn't delete receipt filter %s.", filter_name) raise