sendEmail method

Future<bool> sendEmail(
  1. String subject,
  2. String bodyHtml,
  3. String bodyText,
  4. Iterable<MailAddress> recipients, {
  5. Map<String, MailerAttachment> images = const {},
  6. Map<String, MailerAttachment> attachments = const {},
  7. Iterable<MailAddress> replyTo = const [],
  8. Iterable<MailAddress> sendFyiTo = const [],
})

Implementation

Future<bool> sendEmail(
  String subject,
  String bodyHtml,
  String bodyText,
  Iterable<MailAddress> recipients, {
  Map<String, MailerAttachment> images = const {},
  Map<String, MailerAttachment> attachments = const {},
  Iterable<MailAddress> replyTo = const [],
  Iterable<MailAddress> sendFyiTo = const [],
}) async {
  var type = config.getRequired<String>('mailer.type');
  if (type == 'smtp') {
    var ret = await _sendSmtpEmail(subject, bodyHtml, bodyText, recipients, replyTo: replyTo, images: images, attachments: attachments);
    if (sendFyiTo.isNotEmpty) {
      for (var fyiRecipient in sendFyiTo) {
        String fyiSubject = 'FYI: ${recipients.join(',')} $subject';
        await _sendSmtpEmail(fyiSubject, bodyHtml, bodyText, [fyiRecipient], replyTo: replyTo, images: images, attachments: attachments);
      }
    }
    return ret;
  } else if (type == 'print') {
    return await _printEmail(subject, bodyText, recipients, replyTo: replyTo, images: images, attachments: attachments);
  } else {
    throw Exception('undefined mailer type');
  }
}