send_email
async
¶
send_email(
source: Address,
destination: Destination,
message: Message,
*,
config_overrides: Optional[AsyncSESClientConfig] = None,
reply_to_addresses: Optional[AddressList] = None,
return_path: Optional[Address] = None,
source_arn: Optional[AmazonResourceName] = None,
return_path_arn: Optional[AmazonResourceName] = None,
tags: Optional[MessageTagList] = None,
configuration_set_name: Optional[ConfigurationSetName] = None,
) -> SendEmailResponse
Composes an email message and immediately queues it for sending. To send email using this operation, your message must meet the following requirements:
-
The message must be sent from a verified email address or domain. If you attempt to send email using a non-verified address or domain, the operation results in an "Email address not verified" error.
-
If your account is still in the Amazon SES sandbox, you may only send to verified addresses or domains, or to email addresses associated with the Amazon SES Mailbox Simulator. For more information, see Verifying Email Addresses and Domains in the Amazon SES Developer Guide.
-
The maximum message size is 10 MB.
-
The message must include at least one recipient email address. The recipient address can be a To: address, a CC: address, or a BCC: address. If a recipient email address is invalid (that is, it is not in the format UserName@[SubDomain.]Domain.TopLevelDomain), the entire message is rejected, even if the message contains other recipients that are valid.
-
The message may not include more than 50 recipients, across the To:, CC: and BCC: fields. If you need to send an email message to a larger audience, you can divide your recipient list into groups of 50 or fewer, and then call the
SendEmailoperation several times to send the message to each group.
For every message that you send, the total number of recipients (including each recipient in the To:, CC: and BCC: fields) is counted against the maximum number of emails you can send in a 24-hour period (your sending quota). For more information about sending quotas in Amazon SES, see Managing Your Amazon SES Sending Limits in the Amazon SES Developer Guide.
Parameters:
-
source(Address) –The email address that is sending the email. This email address must be either individually verified with Amazon SES, or from a domain that has been verified with Amazon SES. For information about verifying identities, see the Amazon SES Developer Guide.
If you are sending on behalf of another user and have been permitted to do so by a sending authorization policy, then you must also specify the
SourceArnparameter. For more information about sending authorization, see the Amazon SES Developer Guide.Amazon SES does not support the SMTPUTF8 extension, as described in RFC6531. For this reason, the email address string must be 7-bit ASCII. If you want to send to or from email addresses that contain Unicode characters in the domain part of an address, you must encode the domain using Punycode. Punycode is not permitted in the local part of the email address (the part before the @ sign) nor in the "friendly from" name. If you want to use Unicode characters in the "friendly from" name, you must encode the "friendly from" name using MIME encoded-word syntax, as described in Sending raw email using the Amazon SES API. For more information about Punycode, see RFC 3492.
-
destination(Destination) –The destination for this email, composed of To:, CC:, and BCC: fields.
-
message(Message) –The message to be sent.
-
reply_to_addresses(Optional[AddressList], default:None) –The reply-to email address(es) for the message. If the recipient replies to the message, each reply-to address receives the reply.
-
return_path(Optional[Address], default:None) –The email address that bounces and complaints are forwarded to when feedback forwarding is enabled. If the message cannot be delivered to the recipient, then an error message is returned from the recipient's ISP; this message is forwarded to the email address specified by the
ReturnPathparameter. TheReturnPathparameter is never overwritten. This email address must be either individually verified with Amazon SES, or from a domain that has been verified with Amazon SES. -
source_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 send for the email address specified in the
Sourceparameter.For example, if the owner of
example.com(which has ARNarn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it that authorizes you to send from[email protected], then you would specify theSourceArnto bearn:aws:ses:us-east-1:123456789012:identity/example.com, and theSourceto be[email protected].For more information about sending authorization, see the Amazon SES Developer Guide.
-
return_path_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
ReturnPathparameter.For example, if the owner of
example.com(which has ARNarn: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 theReturnPathArnto bearn:aws:ses:us-east-1:123456789012:identity/example.com, and theReturnPathto be[email protected].For more information about sending authorization, see the Amazon SES Developer Guide.
-
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
SendEmail. 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 you send an email using
SendEmail.
Raises:
-
AccountSendingPausedException–Indicates that email sending is disabled for your entire Amazon SES account.
You can enable or disable email sending for your Amazon SES account using UpdateAccountSendingEnabled.
-
ConfigurationSetDoesNotExistException–Indicates that the configuration set does not exist.
-
ConfigurationSetSendingPausedException–Indicates that email sending is disabled for the configuration set.
You can enable or disable email sending for a configuration set using UpdateConfigurationSetSendingEnabled.
-
MailFromDomainNotVerifiedException–Indicates that the message could not be sent because Amazon SES could not read the MX record required to use the specified MAIL FROM domain. For information about editing the custom MAIL FROM domain settings for an identity, see the Amazon SES Developer Guide.
-
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.
Examples:
SendEmail The following example sends a formatted email:
>>> await client.send_email(source='[email protected]', destination={'ToAddresses': ['[email protected]', '[email protected]'], 'CcAddresses': ['[email protected]'], 'BccAddresses': []}, message={'Subject': {'Data': 'Test email', 'Charset': 'UTF-8'}, 'Body': {'Text': {'Data': 'This is the message body in text format.', 'Charset': 'UTF-8'}, 'Html': {'Data': 'This message body contains HTML formatting. It can, for example, contain links like this one: <a class="ulink" href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide" target="_blank">Amazon SES Developer Guide</a>.', 'Charset': 'UTF-8'}}}, reply_to_addresses=[], return_path='', source_arn='', return_path_arn='')
Source code in docs_src/capo_ses/_services/async_ses.py
2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 | |