SESV2.Client.
send_email
(**kwargs)¶Sends an email message. You can use the Amazon SES API v2 to send the following types of messages:
See also: AWS API Documentation
Request Syntax
response = client.send_email(
FromEmailAddress='string',
FromEmailAddressIdentityArn='string',
Destination={
'ToAddresses': [
'string',
],
'CcAddresses': [
'string',
],
'BccAddresses': [
'string',
]
},
ReplyToAddresses=[
'string',
],
FeedbackForwardingEmailAddress='string',
FeedbackForwardingEmailAddressIdentityArn='string',
Content={
'Simple': {
'Subject': {
'Data': 'string',
'Charset': 'string'
},
'Body': {
'Text': {
'Data': 'string',
'Charset': 'string'
},
'Html': {
'Data': 'string',
'Charset': 'string'
}
}
},
'Raw': {
'Data': b'bytes'
},
'Template': {
'TemplateName': 'string',
'TemplateArn': 'string',
'TemplateData': 'string'
}
},
EmailTags=[
{
'Name': 'string',
'Value': 'string'
},
],
ConfigurationSetName='string',
ListManagementOptions={
'ContactListName': 'string',
'TopicName': 'string'
}
)
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 sender@example.com, then you would specify the FromEmailAddressIdentityArn
to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the FromEmailAddress
to be sender@example.com.
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.
An object that contains the recipients of the email message.
An array that contains the email addresses of the "To" recipients for the email.
An array that contains the email addresses of the "CC" (carbon copy) recipients for the email.
An array that contains the email addresses of the "BCC" (blind carbon copy) recipients for the email.
The "Reply-to" email addresses for the message. When the recipient replies to the message, each Reply-to address receives the reply.
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 feedback@example.com, then you would specify the FeedbackForwardingEmailAddressIdentityArn
to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the FeedbackForwardingEmailAddress
to be feedback@example.com.
For more information about sending authorization, see the Amazon SES Developer Guide.
[REQUIRED]
An object that contains the body of the message. You can send either a Simple message Raw message or a template Message.
The simple email message. The message consists of a subject and a message body.
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.
The content of the message itself.
The character set for the content. Because of the constraints of the SMTP protocol, Amazon SES 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
.
The body of the message. You can specify an HTML version of the message, a text-only version of the message, or both.
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.
The content of the message itself.
The character set for the content. Because of the constraints of the SMTP protocol, Amazon SES 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
.
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.
The content of the message itself.
The character set for the content. Because of the constraints of the SMTP protocol, Amazon SES 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
.
The raw email message. The message has to meet the following criteria:
The raw email message. The message has to meet the following criteria:
The template to use for the email message.
The name of the template. You will refer to this name when you send email using the SendTemplatedEmail
or SendBulkTemplatedEmail
operations.
The Amazon Resource Name (ARN) of the template.
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.
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.
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.
The name of the message tag. The message tag name has to meet the following criteria:
The value of the message tag. The message tag value has to meet the following criteria:
An object used to specify a list or topic to which an email belongs, which will be used when a contact chooses to unsubscribe.
The name of the contact list.
The name of the topic.
dict
Response Syntax
{
'MessageId': 'string'
}
Response Structure
(dict) --
A unique message ID that you receive when an email is accepted for sending.
MessageId (string) --
A unique identifier for the message that is generated when the message is accepted.
Note
It's possible for Amazon SES to accept a message without sending it. This can happen when the message that you're trying to send has an attachment contains a virus, or when you send a templated email that contains invalid personalization content, for example.
Exceptions
SESV2.Client.exceptions.TooManyRequestsException
SESV2.Client.exceptions.LimitExceededException
SESV2.Client.exceptions.AccountSuspendedException
SESV2.Client.exceptions.SendingPausedException
SESV2.Client.exceptions.MessageRejected
SESV2.Client.exceptions.MailFromDomainNotVerifiedException
SESV2.Client.exceptions.NotFoundException
SESV2.Client.exceptions.BadRequestException