send_email

send_email(**kwargs)

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.

See also: AWS API Documentation

Request Syntax

response = client.send_email(
    FromEmailAddress='string',
    Destination={
        'ToAddresses': [
            'string',
        ],
        'CcAddresses': [
            'string',
        ],
        'BccAddresses': [
            'string',
        ]
    },
    ReplyToAddresses=[
        'string',
    ],
    FeedbackForwardingEmailAddress='string',
    Content={
        'Simple': {
            'Subject': {
                'Data': 'string',
                'Charset': 'string'
            },
            'Body': {
                'Text': {
                    'Data': 'string',
                    'Charset': 'string'
                },
                'Html': {
                    'Data': 'string',
                    'Charset': 'string'
                }
            }
        },
        'Raw': {
            'Data': b'bytes'
        },
        'Template': {
            'TemplateArn': 'string',
            'TemplateData': 'string'
        }
    },
    EmailTags=[
        {
            'Name': 'string',
            'Value': 'string'
        },
    ],
    ConfigurationSetName='string'
)
Parameters
  • FromEmailAddress (string) -- 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 (dict) --

    [REQUIRED]

    An object that contains the recipients of the email message.

    • ToAddresses (list) --

      An array that contains the email addresses of the "To" recipients for the email.

      • (string) --
    • CcAddresses (list) --

      An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.

      • (string) --
    • BccAddresses (list) --

      An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.

      • (string) --
  • ReplyToAddresses (list) --

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

    • (string) --
  • FeedbackForwardingEmailAddress (string) -- The address that Amazon Pinpoint should send bounce and complaint notifications to.
  • Content (dict) --

    [REQUIRED]

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

    • Simple (dict) --

      The simple email message. The message consists of a subject and a message body.

      • Subject (dict) -- [REQUIRED]

        The subject line of the email. The subject line can only contain 7-bit ASCII characters. However, you can specify non-ASCII characters in the subject line by using encoded-word syntax, as described in RFC 2047.

        • Data (string) -- [REQUIRED]

          The content of the message itself.

        • Charset (string) --

          The character set for the content. Because of the constraints of the SMTP protocol, Amazon Pinpoint uses 7-bit ASCII by default. If the text includes characters outside of the ASCII range, you have to specify a character set. For example, you could specify UTF-8 , ISO-8859-1 , or Shift_JIS .

      • Body (dict) -- [REQUIRED]

        The body of the message. You can specify an HTML version of the message, a text-only version of the message, or both.

        • Text (dict) --

          An object that represents the version of the message that is displayed in email clients that don't support HTML, or clients where the recipient has disabled HTML rendering.

          • Data (string) -- [REQUIRED]

            The content of the message itself.

          • Charset (string) --

            The character set for the content. Because of the constraints of the SMTP protocol, Amazon Pinpoint uses 7-bit ASCII by default. If the text includes characters outside of the ASCII range, you have to specify a character set. For example, you could specify UTF-8 , ISO-8859-1 , or Shift_JIS .

        • Html (dict) --

          An object that represents the version of the message that is displayed in email clients that support HTML. HTML messages can include formatted text, hyperlinks, images, and more.

          • Data (string) -- [REQUIRED]

            The content of the message itself.

          • Charset (string) --

            The character set for the content. Because of the constraints of the SMTP protocol, Amazon Pinpoint uses 7-bit ASCII by default. If the text includes characters outside of the ASCII range, you have to specify a character set. For example, you could specify UTF-8 , ISO-8859-1 , or Shift_JIS .

    • Raw (dict) --

      The raw email message. The message has to meet the following criteria:

      • The message has to contain a header and a body, separated by one blank line.
      • All of the required header fields must be present in the message.
      • Each part of a multipart MIME message must be formatted properly.
      • If you include attachments, they must be in a file format that Amazon Pinpoint supports.
      • The entire message must be Base64 encoded.
      • If any of the MIME parts in your message contain content that is outside of the 7-bit ASCII character range, you should encode that content to ensure that recipients' email clients render the message properly.
      • The length of any single line of text in the message can't exceed 1,000 characters. This restriction is defined in RFC 5321.
      • Data (bytes) -- [REQUIRED]

        The raw email message. The message has to meet the following criteria:

        • The message has to contain a header and a body, separated by one blank line.
        • All of the required header fields must be present in the message.
        • Each part of a multipart MIME message must be formatted properly.
        • Attachments must be in a file format that Amazon Pinpoint supports.
        • The entire message must be Base64 encoded.
        • If any of the MIME parts in your message contain content that is outside of the 7-bit ASCII character range, you should encode that content to ensure that recipients' email clients render the message properly.
        • The length of any single line of text in the message can't exceed 1,000 characters. This restriction is defined in RFC 5321.
    • Template (dict) --

      The template to use for the email message.

      • TemplateArn (string) --

        The Amazon Resource Name (ARN) of the template.

      • TemplateData (string) --

        An object that defines the values to use for message variables in the template. This object is a set of key-value pairs. Each key defines a message variable in the template. The corresponding value defines the value to use for that variable.

  • EmailTags (list) --

    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.

    • (dict) --

      Contains the name and value of a tag that you apply to an email. You can use message tags when you publish email sending events.

      • Name (string) -- [REQUIRED]

        The name of the message tag. The message tag name has to meet the following criteria:

        • It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-).
        • It can contain no more than 256 characters.
      • Value (string) -- [REQUIRED]

        The value of the message tag. The message tag value has to meet the following criteria:

        • It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-).
        • It can contain no more than 256 characters.
  • ConfigurationSetName (string) -- The name of the configuration set that you want to use when sending the email.
Return type

dict

Returns

Response Syntax

{
    'MessageId': 'string'
}

Response Structure

  • (dict) --

    A unique message ID that you receive when Amazon Pinpoint accepts an email for sending.

    • MessageId (string) --

      A unique identifier for the message that is generated when Amazon Pinpoint accepts the message.

      Note

      It is possible for Amazon Pinpoint to accept a message without sending it. This can happen when the message you're trying to send has an attachment doesn't pass a virus check, or when you send a templated email that contains invalid personalization content, for example.

Exceptions

  • PinpointEmail.Client.exceptions.TooManyRequestsException
  • PinpointEmail.Client.exceptions.LimitExceededException
  • PinpointEmail.Client.exceptions.AccountSuspendedException
  • PinpointEmail.Client.exceptions.SendingPausedException
  • PinpointEmail.Client.exceptions.MessageRejected
  • PinpointEmail.Client.exceptions.MailFromDomainNotVerifiedException
  • PinpointEmail.Client.exceptions.NotFoundException
  • PinpointEmail.Client.exceptions.BadRequestException