send method

Future<void> send()

Send the email immediately

Implementation

Future<void> send() async {
  validate();
  final htmlContent = await _renderTemplate();

  final mail = mailer.Mail().toMany(to).subject(subject).html(htmlContent);

  // Add optional fields
  if (cc.isNotEmpty) mail.ccMany(cc);
  if (bcc.isNotEmpty) mail.bccMany(bcc);
  if (from != null) {
    // Note: You might need to extend your Mail class to support custom from
  }

  await mail.sendMail();
}