sendTemplatedEmail method
Composes an email message using an email template and immediately queues it for sending.
In order to send email using the SendTemplatedEmail
operation, your call to the API must meet the following requirements:
- The call must refer to an existing email template. You can create email templates using the CreateTemplate operation.
- The message must be sent from a verified email address or domain.
- 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.
-
Calls to the
SendTemplatedEmail
operation may only include oneDestination
parameter. A destination is a set of recipients who will receive the same version of the email. TheDestination
parameter can include up to 50 recipients, across the To:, CC: and BCC: fields. -
The
Destination
parameter 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 will be rejected, even if the message contains other recipients that are valid.
Implementation
Future<SendTemplatedEmailResponse> sendTemplatedEmail({
required Destination destination,
required String source,
required String template,
required String templateData,
String? configurationSetName,
List<String>? replyToAddresses,
String? returnPath,
String? returnPathArn,
String? sourceArn,
List<MessageTag>? tags,
String? templateArn,
}) async {
ArgumentError.checkNotNull(destination, 'destination');
ArgumentError.checkNotNull(source, 'source');
ArgumentError.checkNotNull(template, 'template');
ArgumentError.checkNotNull(templateData, 'templateData');
_s.validateStringLength(
'templateData',
templateData,
0,
262144,
isRequired: true,
);
final $request = <String, dynamic>{};
$request['Destination'] = destination;
$request['Source'] = source;
$request['Template'] = template;
$request['TemplateData'] = templateData;
configurationSetName?.also((arg) => $request['ConfigurationSetName'] = arg);
replyToAddresses?.also((arg) => $request['ReplyToAddresses'] = arg);
returnPath?.also((arg) => $request['ReturnPath'] = arg);
returnPathArn?.also((arg) => $request['ReturnPathArn'] = arg);
sourceArn?.also((arg) => $request['SourceArn'] = arg);
tags?.also((arg) => $request['Tags'] = arg);
templateArn?.also((arg) => $request['TemplateArn'] = arg);
final $result = await _protocol.send(
$request,
action: 'SendTemplatedEmail',
version: '2010-12-01',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
shape: shapes['SendTemplatedEmailRequest'],
shapes: shapes,
resultWrapper: 'SendTemplatedEmailResult',
);
return SendTemplatedEmailResponse.fromXml($result);
}