sendSimpleEmail method

Future<SendEmailResponse> sendSimpleEmail({
  1. required String from,
  2. required List<String> to,
  3. required String subject,
  4. String? body,
  5. String? htmlBody,
  6. List<String>? cc,
  7. List<String>? bcc,
})

Convenience wrapper for sending a basic email with string addresses.

Example:

final response = await client.sendSimpleEmail(
  from: 'noreply@example.com',
  to: ['jane@example.com'],
  subject: 'Hello',
  body: 'Plain text body',
  htmlBody: '<p>Plain text body</p>',
);

Implementation

Future<SendEmailResponse> sendSimpleEmail({
  required String from,
  required List<String> to,
  required String subject,
  String? body,
  String? htmlBody,
  List<String>? cc,
  List<String>? bcc,
}) async {
  final emailRequest = SendEmailRequest(
    from: EmailAddress(from),
    to: to.map((e) => EmailAddress(e)).toList(),
    cc: cc?.map((e) => EmailAddress(e)).toList(),
    bcc: bcc?.map((e) => EmailAddress(e)).toList(),
    subject: subject,
    textBody: body,
    htmlBody: htmlBody,
  );

  return sendEmail(emailRequest);
}