Skip to content

create_receipt_rule

create_receipt_rule(
    rule_set_name: ReceiptRuleSetName,
    rule: ReceiptRule,
    *,
    config_overrides: Optional[SESClientConfig] = None,
    after: Optional[ReceiptRuleName] = None,
) -> CreateReceiptRuleResponse

Creates a receipt rule.

For information about setting up receipt rules, see the Amazon SES Developer Guide.

You can execute this operation no more than once per second.

Parameters:

  • rule_set_name (ReceiptRuleSetName) –

    The name of the rule set where the receipt rule is added.

  • after (Optional[ReceiptRuleName], default: None ) –

    The name of an existing rule after which the new rule is placed. If this parameter is null, the new rule is inserted at the beginning of the rule list.

  • rule (ReceiptRule) –

    A data structure that contains the specified rule's name, actions, recipients, domains, enabled status, scan status, and TLS policy.

Raises:

Examples:

CreateReceiptRule The following example creates a new receipt rule:

>>> client.create_receipt_rule(rule_set_name='MyRuleSet', after='', rule={'TlsPolicy': 'Optional', 'Enabled': True, 'Name': 'MyRule', 'Actions': [{'S3Action': {'ObjectKeyPrefix': 'email', 'BucketName': 'MyBucket'}}], 'ScanEnabled': True})
Source code in docs_src/capo_ses/_services/ses.py
def create_receipt_rule(
    self,
    rule_set_name: "capo_ses.types.receipt_rule_set_name.ReceiptRuleSetName",
    rule: "capo_ses.types.receipt_rule.ReceiptRule",
    *,
    config_overrides: Optional[SESClientConfig] = None,
    after: Optional["capo_ses.types.receipt_rule_name.ReceiptRuleName"] = None,
) -> "capo_ses.types.create_receipt_rule_response.CreateReceiptRuleResponse":
    """<p>Creates a receipt rule.</p> <p>For information about setting up receipt rules, see the <a href="https://docs.aws.amazon.com/ses/latest/dg/receiving-email-receipt-rules-console-walkthrough.html">Amazon SES Developer Guide</a>.</p> <p>You can execute this operation no more than once per second.</p>

    Args:
        rule_set_name: <p>The name of the rule set where the receipt rule is added.</p>
        after: <p>The name of an existing rule after which the new rule is placed. If this parameter is null, the new rule is inserted at the beginning of the rule list.</p>
        rule: <p>A data structure that contains the specified rule's name, actions, recipients, domains, enabled status, scan status, and TLS policy.</p>

    Raises:
        capo_ses.errors.already_exists_exception.AlreadyExistsException: <p>Indicates that a resource could not be created because of a naming conflict.</p>
        capo_ses.errors.invalid_lambda_function_exception.InvalidLambdaFunctionException: <p>Indicates that the provided Amazon Web Services Lambda function is invalid, or that Amazon SES could not execute the provided function, possibly due to permissions issues. For information about giving permissions, see the <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-permissions.html">Amazon SES Developer Guide</a>.</p>
        capo_ses.errors.invalid_s3_configuration_exception.InvalidS3ConfigurationException: <p>Indicates that the provided Amazon S3 bucket or Amazon Web Services KMS encryption key is invalid, or that Amazon SES could not publish to the bucket, possibly due to permissions issues. For information about giving permissions, see the <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-permissions.html">Amazon SES Developer Guide</a>.</p>
        capo_ses.errors.invalid_sns_topic_exception.InvalidSnsTopicException: <p>Indicates that the provided Amazon SNS topic is invalid, or that Amazon SES could not publish to the topic, possibly due to permissions issues. For information about giving permissions, see the <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-permissions.html">Amazon SES Developer Guide</a>.</p>
        capo_ses.errors.limit_exceeded_exception.LimitExceededException: <p>Indicates that a resource could not be created because of service limits. For a list of Amazon SES limits, see the <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/limits.html">Amazon SES Developer Guide</a>.</p>
        capo_ses.errors.rule_does_not_exist_exception.RuleDoesNotExistException: <p>Indicates that the provided receipt rule does not exist.</p>
        capo_ses.errors.rule_set_does_not_exist_exception.RuleSetDoesNotExistException: <p>Indicates that the provided receipt rule set does not exist.</p>
        capo_ses.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        CreateReceiptRule
        The following example creates a new receipt rule:

        >>> client.create_receipt_rule(rule_set_name='MyRuleSet', after='', rule={'TlsPolicy': 'Optional', 'Enabled': True, 'Name': 'MyRule', 'Actions': [{'S3Action': {'ObjectKeyPrefix': 'email', 'BucketName': 'MyBucket'}}], 'ScanEnabled': True})
    """

    def _handler(
        req: "OperationRequest[capo_ses.types.create_receipt_rule_request.CreateReceiptRuleRequest]",
    ) -> OperationResponse[
        "capo_ses.types.create_receipt_rule_response.CreateReceiptRuleResponse"
    ]:
        import capo_ses._operations.simple_email_service.create_receipt_rule

        output, http_response = (
            capo_ses._operations.simple_email_service.create_receipt_rule.create_receipt_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateReceiptRule")
    )
    input_: capo_ses.types.create_receipt_rule_request.CreateReceiptRuleRequest = {
        "rule_set_name": rule_set_name,
        "rule": rule,
    }
    if after is not None:
        input_["after"] = after

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output