Skip to content

send_email

send_email(
    destination: Destination,
    content: EmailContent,
    *,
    config_overrides: Optional[PinpointEmailClientConfig] = None,
    from_email_address: Optional[EmailAddress] = None,
    reply_to_addresses: Optional[EmailAddressList] = None,
    feedback_forwarding_email_address: Optional[EmailAddress] = None,
    email_tags: Optional[MessageTagList] = None,
    configuration_set_name: Optional[ConfigurationSetName] = None,
) -> SendEmailResponse

Sends an email message. You can use the Amazon Pinpoint Email API to send two 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 Pinpoint 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.

Parameters:

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

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

  • destination (Destination) –

    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 Amazon Pinpoint should send bounce and complaint notifications to.

  • content (EmailContent) –

    An object that contains the body of the message. You can send either a Simple message or a Raw 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 that you want to use when sending the email.

Raises:

Source code in docs_src/capo_pinpoint_email/_services/pinpoint_email.py
def send_email(
    self,
    destination: "capo_pinpoint_email.types.destination.Destination",
    content: "capo_pinpoint_email.types.email_content.EmailContent",
    *,
    config_overrides: Optional[PinpointEmailClientConfig] = None,
    from_email_address: Optional[
        "capo_pinpoint_email.types.email_address.EmailAddress"
    ] = None,
    reply_to_addresses: Optional[
        "capo_pinpoint_email.types.email_address_list.EmailAddressList"
    ] = None,
    feedback_forwarding_email_address: Optional[
        "capo_pinpoint_email.types.email_address.EmailAddress"
    ] = None,
    email_tags: Optional[
        "capo_pinpoint_email.types.message_tag_list.MessageTagList"
    ] = None,
    configuration_set_name: Optional[
        "capo_pinpoint_email.types.configuration_set_name.ConfigurationSetName"
    ] = None,
) -> "capo_pinpoint_email.types.send_email_response.SendEmailResponse":
    """<p>Sends an email message. You can use the Amazon Pinpoint Email API to send two 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 Pinpoint 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> </ul>

    Args:
        from_email_address: <p>The email address that you want to use as the "From" address for the email. The address that you specify has to be verified. </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 Amazon Pinpoint should send bounce and complaint notifications to.</p>
        content: <p>An object that contains the body of the message. You can send either a Simple message or a Raw 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 that you want to use when sending the email.</p>

    Raises:
        capo_pinpoint_email.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_pinpoint_email.errors.bad_request_exception.BadRequestException: <p>The input you provided is invalid.</p>
        capo_pinpoint_email.errors.limit_exceeded_exception.LimitExceededException: <p>There are too many instances of the specified resource type.</p>
        capo_pinpoint_email.errors.mail_from_domain_not_verified_exception.MailFromDomainNotVerifiedException: <p>The message can't be sent because the sending domain isn't verified.</p>
        capo_pinpoint_email.errors.message_rejected.MessageRejected: <p>The message can't be sent because it contains invalid content.</p>
        capo_pinpoint_email.errors.not_found_exception.NotFoundException: <p>The resource you attempted to access doesn't exist.</p>
        capo_pinpoint_email.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_pinpoint_email.errors.too_many_requests_exception.TooManyRequestsException: <p>Too many requests have been made to the operation.</p>
        capo_pinpoint_email.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

        output, http_response = (
            capo_pinpoint_email._operations.amazon_pinpoint_email_service.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_pinpoint_email.types.send_email_request.SendEmailRequest = {
        "destination": destination,
        "content": content,
    }
    if from_email_address is not None:
        input_["from_email_address"] = from_email_address
    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 email_tags is not None:
        input_["email_tags"] = email_tags
    if configuration_set_name is not None:
        input_["configuration_set_name"] = configuration_set_name

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