send method

Future<void> send()

Send immediately

Implementation

Future<void> send() async {
  try {
    validate();

    // Render .flint.html template into HTML
    final html = await FlintTemplateEngine().render(view, data: data);
    final text = _stripHtmlTags(html);

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

    if (cc.isNotEmpty) mail.ccMany(cc);
    if (bcc.isNotEmpty) mail.bccMany(bcc);

    await mail.sendMail();
    print('✅ Email sent to: ${to.join(', ')}');
  } catch (e) {
    print('❌ Failed to send view mail: $e');
    rethrow;
  }
}