sendTemplatedEmail method

Future<SendTemplatedEmailResponse> sendTemplatedEmail({
  1. required Destination destination,
  2. required String source,
  3. required String template,
  4. required String templateData,
  5. String? configurationSetName,
  6. List<String>? replyToAddresses,
  7. String? returnPath,
  8. String? returnPathArn,
  9. String? sourceArn,
  10. List<MessageTag>? tags,
  11. String? templateArn,
})

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 one Destination parameter. A destination is a set of recipients who will receive the same version of the email. The Destination 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);
}