Skip to content

send_email

send_email(
    content: EmailContent,
    *,
    config_overrides: Optional[SESv2ClientConfig] = None,
    from_email_address: Optional[EmailAddress] = None,
    from_email_address_identity_arn: Optional[AmazonResourceName] = None,
    destination: Optional[Destination] = None,
    reply_to_addresses: Optional[EmailAddressList] = None,
    feedback_forwarding_email_address: Optional[EmailAddress] = None,
    feedback_forwarding_email_address_identity_arn: Optional[AmazonResourceName] = None,
    email_tags: Optional[MessageTagList] = None,
    configuration_set_name: Optional[ConfigurationSetName] = None,
    endpoint_id: Optional[EndpointId] = None,
    tenant_name: Optional[TenantName] = None,
    list_management_options: Optional[ListManagementOptions] = None,
    configuration_overrides: Optional[ConfigurationOverrides] = None,
) -> SendEmailResponse

Sends an email message. You can use the Amazon SES API v2 to send the following types of messages:

  • Simple – A standard email message. When you create this type of message, you specify the sender, the recipient, and the message body, and Amazon SES assembles the message for you.

  • Raw – A raw, MIME-formatted email message. When you send this type of email, you have to specify all of the message headers, as well as the message body. You can use this message type to send messages that contain attachments. The message that you specify has to be a valid MIME message.

  • Templated – A message that contains personalization tags. When you send this type of email, Amazon SES API v2 automatically replaces the tags with values that you specify.

Parameters:

  • from_email_address (Optional[EmailAddress], default: None ) –

    The email address to use as the "From" address for the email. The address that you specify has to be verified.

  • from_email_address_identity_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 email address specified in the FromEmailAddress parameter.

    For example, if the owner of example.com (which has ARN arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it that authorizes you to use [email protected], then you would specify the FromEmailAddressIdentityArn to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the FromEmailAddress to be [email protected].

    For more information about sending authorization, see the Amazon SES Developer Guide.

    For Raw emails, the FromEmailAddressIdentityArn value overrides the X-SES-SOURCE-ARN and X-SES-FROM-ARN headers specified in raw email message content.

  • destination (Optional[Destination], default: None ) –

    An object that contains the recipients of the email message.

  • reply_to_addresses (Optional[EmailAddressList], default: None ) –

    The "Reply-to" email addresses for the message. When the recipient replies to the message, each Reply-to address receives the reply.

  • feedback_forwarding_email_address (Optional[EmailAddress], default: None ) –

    The address that you want bounce and complaint notifications to be sent to.

  • feedback_forwarding_email_address_identity_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 email address specified in the FeedbackForwardingEmailAddress parameter.

    For example, if the owner of example.com (which has ARN arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it that authorizes you to use [email protected], then you would specify the FeedbackForwardingEmailAddressIdentityArn to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the FeedbackForwardingEmailAddress to be [email protected].

    For more information about sending authorization, see the Amazon SES Developer Guide.

  • content (EmailContent) –

    An object that contains the body of the message. You can send either a Simple message, Raw message, or a Templated message.

  • email_tags (Optional[MessageTagList], default: None ) –

    A list of tags, in the form of name/value pairs, to apply to an email that you send using the SendEmail operation. Tags correspond to characteristics of the email that you define, so that you can publish email sending events.

  • configuration_set_name (Optional[ConfigurationSetName], default: None ) –

    The name of the configuration set to use when sending the email.

  • endpoint_id (Optional[EndpointId], default: None ) –

    The ID of the multi-region endpoint (global-endpoint).

  • tenant_name (Optional[TenantName], default: None ) –

    The name of the tenant through which this email will be sent.

    The email sending operation will only succeed if all referenced resources (identities, configuration sets, and templates) are associated with this tenant.

  • list_management_options (Optional[ListManagementOptions], default: None ) –

    An object used to specify a list or topic to which an email belongs, which will be used when a contact chooses to unsubscribe.

  • configuration_overrides (Optional[ConfigurationOverrides], default: None ) –

    An object that overrides, for this message only, settings that would otherwise apply to it. Each setting that you don't override keeps the value that already applies.

Raises:

Source code in docs_src/capo_sesv2/_services/se_sv2.py
def send_email(
    self,
    content: "capo_sesv2.types.email_content.EmailContent",
    *,
    config_overrides: Optional[SESv2ClientConfig] = None,
    from_email_address: Optional[
        "capo_sesv2.types.email_address.EmailAddress"
    ] = None,
    from_email_address_identity_arn: Optional[
        "capo_sesv2.types.amazon_resource_name.AmazonResourceName"
    ] = None,
    destination: Optional["capo_sesv2.types.destination.Destination"] = None,
    reply_to_addresses: Optional[
        "capo_sesv2.types.email_address_list.EmailAddressList"
    ] = None,
    feedback_forwarding_email_address: Optional[
        "capo_sesv2.types.email_address.EmailAddress"
    ] = None,
    feedback_forwarding_email_address_identity_arn: Optional[
        "capo_sesv2.types.amazon_resource_name.AmazonResourceName"
    ] = None,
    email_tags: Optional["capo_sesv2.types.message_tag_list.MessageTagList"] = None,
    configuration_set_name: Optional[
        "capo_sesv2.types.configuration_set_name.ConfigurationSetName"
    ] = None,
    endpoint_id: Optional["capo_sesv2.types.endpoint_id.EndpointId"] = None,
    tenant_name: Optional["capo_sesv2.types.tenant_name.TenantName"] = None,
    list_management_options: Optional[
        "capo_sesv2.types.list_management_options.ListManagementOptions"
    ] = None,
    configuration_overrides: Optional[
        "capo_sesv2.types.configuration_overrides.ConfigurationOverrides"
    ] = None,
) -> "capo_sesv2.types.send_email_response.SendEmailResponse":
    """<p>Sends an email message. You can use the Amazon SES API v2 to send the following types of messages:</p> <ul> <li> <p> <b>Simple</b> – A standard email message. When you create this type of message, you specify the sender, the recipient, and the message body, and Amazon SES assembles the message for you.</p> </li> <li> <p> <b>Raw</b> – A raw, MIME-formatted email message. When you send this type of email, you have to specify all of the message headers, as well as the message body. You can use this message type to send messages that contain attachments. The message that you specify has to be a valid MIME message.</p> </li> <li> <p> <b>Templated</b> – A message that contains personalization tags. When you send this type of email, Amazon SES API v2 automatically replaces the tags with values that you specify.</p> </li> </ul>

    Args:
        from_email_address: <p>The email address to use as the "From" address for the email. The address that you specify has to be verified. </p>
        from_email_address_identity_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 email address specified in the <code>FromEmailAddress</code> parameter.</p> <p>For example, if the owner of example.com (which has ARN arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it that authorizes you to use [email protected], then you would specify the <code>FromEmailAddressIdentityArn</code> to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the <code>FromEmailAddress</code> to be [email protected].</p> <p>For more information about sending authorization, see the <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html">Amazon SES Developer Guide</a>.</p> <p>For Raw emails, the <code>FromEmailAddressIdentityArn</code> value overrides the X-SES-SOURCE-ARN and X-SES-FROM-ARN headers specified in raw email message content.</p>
        destination: <p>An object that contains the recipients of the email message.</p>
        reply_to_addresses: <p>The "Reply-to" email addresses for the message. When the recipient replies to the message, each Reply-to address receives the reply.</p>
        feedback_forwarding_email_address: <p>The address that you want bounce and complaint notifications to be sent to.</p>
        feedback_forwarding_email_address_identity_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 email address specified in the <code>FeedbackForwardingEmailAddress</code> parameter.</p> <p>For example, if the owner of example.com (which has ARN arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it that authorizes you to use [email protected], then you would specify the <code>FeedbackForwardingEmailAddressIdentityArn</code> to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the <code>FeedbackForwardingEmailAddress</code> to be [email protected].</p> <p>For more information about sending authorization, see the <a href="https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html">Amazon SES Developer Guide</a>.</p>
        content: <p>An object that contains the body of the message. You can send either a Simple message, Raw message, or a Templated message.</p>
        email_tags: <p>A list of tags, in the form of name/value pairs, to apply to an email that you send using the <code>SendEmail</code> operation. Tags correspond to characteristics of the email that you define, so that you can publish email sending events. </p>
        configuration_set_name: <p>The name of the configuration set to use when sending the email.</p>
        endpoint_id: <p>The ID of the multi-region endpoint (global-endpoint).</p>
        tenant_name: <p>The name of the tenant through which this email will be sent.</p> <note> <p>The email sending operation will only succeed if all referenced resources (identities, configuration sets, and templates) are associated with this tenant. </p> </note>
        list_management_options: <p>An object used to specify a list or topic to which an email belongs, which will be used when a contact chooses to unsubscribe.</p>
        configuration_overrides: <p>An object that overrides, for this message only, settings that would otherwise apply to it. Each setting that you don't override keeps the value that already applies.</p>

    Raises:
        capo_sesv2.errors.account_suspended_exception.AccountSuspendedException: <p>The message can't be sent because the account's ability to send email has been permanently restricted.</p>
        capo_sesv2.errors.bad_request_exception.BadRequestException: <p>The input you provided is invalid.</p>
        capo_sesv2.errors.limit_exceeded_exception.LimitExceededException: <p>There are too many instances of the specified resource type.</p>
        capo_sesv2.errors.mail_from_domain_not_verified_exception.MailFromDomainNotVerifiedException: <p>The message can't be sent because the sending domain isn't verified.</p>
        capo_sesv2.errors.message_rejected.MessageRejected: <p>The message can't be sent because it contains invalid content.</p>
        capo_sesv2.errors.not_found_exception.NotFoundException: <p>The resource you attempted to access doesn't exist.</p>
        capo_sesv2.errors.sending_paused_exception.SendingPausedException: <p>The message can't be sent because the account's ability to send email is currently paused.</p>
        capo_sesv2.errors.too_many_requests_exception.TooManyRequestsException: <p>Too many requests have been made to the operation.</p>
        capo_sesv2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sesv2.types.send_email_request.SendEmailRequest]",
    ) -> OperationResponse[
        "capo_sesv2.types.send_email_response.SendEmailResponse"
    ]:
        import capo_sesv2._operations.simple_email_service_v2.send_email

        output, http_response = (
            capo_sesv2._operations.simple_email_service_v2.send_email.send_email(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SendEmail")
    )
    input_: capo_sesv2.types.send_email_request.SendEmailRequest = {
        "content": content
    }
    if from_email_address is not None:
        input_["from_email_address"] = from_email_address
    if from_email_address_identity_arn is not None:
        input_["from_email_address_identity_arn"] = from_email_address_identity_arn
    if destination is not None:
        input_["destination"] = destination
    if reply_to_addresses is not None:
        input_["reply_to_addresses"] = reply_to_addresses
    if feedback_forwarding_email_address is not None:
        input_["feedback_forwarding_email_address"] = (
            feedback_forwarding_email_address
        )
    if feedback_forwarding_email_address_identity_arn is not None:
        input_["feedback_forwarding_email_address_identity_arn"] = (
            feedback_forwarding_email_address_identity_arn
        )
    if email_tags is not None:
        input_["email_tags"] = email_tags
    if configuration_set_name is not None:
        input_["configuration_set_name"] = configuration_set_name
    if endpoint_id is not None:
        input_["endpoint_id"] = endpoint_id
    if tenant_name is not None:
        input_["tenant_name"] = tenant_name
    if list_management_options is not None:
        input_["list_management_options"] = list_management_options
    if configuration_overrides is not None:
        input_["configuration_overrides"] = configuration_overrides

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