Skip to content

send_bounce async

send_bounce(
    original_message_id: MessageId,
    bounce_sender: Address,
    bounced_recipient_info_list: BouncedRecipientInfoList,
    *,
    config_overrides: Optional[AsyncSESClientConfig] = None,
    explanation: Optional[Explanation] = None,
    message_dsn: Optional[MessageDsn] = None,
    bounce_sender_arn: Optional[AmazonResourceName] = None,
) -> SendBounceResponse

Generates and sends a bounce message to the sender of an email you received through Amazon SES. You can only use this operation on an email up to 24 hours after you receive it.

You cannot use this operation to send generic bounces for mail that was not received by Amazon SES.

For information about receiving email through Amazon SES, see the Amazon SES Developer Guide.

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

Parameters:

  • original_message_id (MessageId) –

    The message ID of the message to be bounced.

  • bounce_sender (Address) –

    The address to use in the "From" header of the bounce message. This must be an identity that you have verified with Amazon SES.

  • explanation (Optional[Explanation], default: None ) –

    Human-readable text for the bounce message to explain the failure. If not specified, the text is auto-generated based on the bounced recipient information.

  • message_dsn (Optional[MessageDsn], default: None ) –

    Message-related DSN fields. If not specified, Amazon SES chooses the values.

  • bounced_recipient_info_list (BouncedRecipientInfoList) –

    A list of recipients of the bounced message, including the information required to create the Delivery Status Notifications (DSNs) for the recipients. You must specify at least one BouncedRecipientInfo in the list.

  • bounce_sender_arn (Optional[AmazonResourceName], default: None ) –

    This parameter is used only for sending authorization. It is the ARN of the identity that is associated with the sending authorization policy that permits you to use the address in the "From" header of the bounce. For more information about sending authorization, see the Amazon SES Developer Guide.

Raises:

  • MessageRejected –

    Indicates that the action failed, and the message could not be sent. Check the error stack for more information about what caused the error.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_ses/_services/async_ses.py
async def send_bounce(
    self,
    original_message_id: "capo_ses.types.message_id.MessageId",
    bounce_sender: "capo_ses.types.address.Address",
    bounced_recipient_info_list: "capo_ses.types.bounced_recipient_info_list.BouncedRecipientInfoList",
    *,
    config_overrides: Optional[AsyncSESClientConfig] = None,
    explanation: Optional["capo_ses.types.explanation.Explanation"] = None,
    message_dsn: Optional["capo_ses.types.message_dsn.MessageDsn"] = None,
    bounce_sender_arn: Optional[
        "capo_ses.types.amazon_resource_name.AmazonResourceName"
    ] = None,
) -> "capo_ses.types.send_bounce_response.SendBounceResponse":
    """<p>Generates and sends a bounce message to the sender of an email you received through Amazon SES. You can only use this operation on an email up to 24 hours after you receive it.</p> <note> <p>You cannot use this operation to send generic bounces for mail that was not received by Amazon SES.</p> </note> <p>For information about receiving email through Amazon SES, see the <a href="https://docs.aws.amazon.com/ses/latest/dg/receiving-email.html">Amazon SES Developer Guide</a>.</p> <p>You can execute this operation no more than once per second.</p>

    Args:
        original_message_id: <p>The message ID of the message to be bounced.</p>
        bounce_sender: <p>The address to use in the "From" header of the bounce message. This must be an identity that you have verified with Amazon SES.</p>
        explanation: <p>Human-readable text for the bounce message to explain the failure. If not specified, the text is auto-generated based on the bounced recipient information.</p>
        message_dsn: <p>Message-related DSN fields. If not specified, Amazon SES chooses the values.</p>
        bounced_recipient_info_list: <p>A list of recipients of the bounced message, including the information required to create the Delivery Status Notifications (DSNs) for the recipients. You must specify at least one <code>BouncedRecipientInfo</code> in the list.</p>
        bounce_sender_arn: <p>This parameter is used only for sending authorization. It is the ARN of the identity that is associated with the sending authorization policy that permits you to use the address in the "From" header of the bounce. For more information about sending authorization, see the <a href="https://docs.aws.amazon.com/ses/latest/dg/sending-authorization.html">Amazon SES Developer Guide</a>.</p>

    Raises:
        capo_ses.errors.message_rejected.MessageRejected: <p>Indicates that the action failed, and the message could not be sent. Check the error stack for more information about what caused the error.</p>
        capo_ses.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ses.types.send_bounce_request.SendBounceRequest]",
    ) -> AsyncOperationResponse[
        "capo_ses.types.send_bounce_response.SendBounceResponse"
    ]:
        import capo_ses._operations.simple_email_service.send_bounce

        (
            output,
            http_response,
        ) = await capo_ses._operations.simple_email_service.send_bounce.async_send_bounce(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SendBounce")
    )
    input_: capo_ses.types.send_bounce_request.SendBounceRequest = {
        "original_message_id": original_message_id,
        "bounce_sender": bounce_sender,
        "bounced_recipient_info_list": bounced_recipient_info_list,
    }
    if explanation is not None:
        input_["explanation"] = explanation
    if message_dsn is not None:
        input_["message_dsn"] = message_dsn
    if bounce_sender_arn is not None:
        input_["bounce_sender_arn"] = bounce_sender_arn

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output