sendMail method

Future<void> sendMail()

Implementation

Future<void> sendMail() async {
  if (_server == null) {
    throw Exception('Mail not configured. Call Mail.setup() first.');
  }

  try {
    final msg = _buildMessage();
    await send(msg, _server!);
    print('✅ Mail sent to: ${_to.join(", ")}');
  } on MailerException catch (e) {
    print('❌ MailerException: $e');
    if (e.problems.isNotEmpty) {
      for (final problem in e.problems) {
        print('  - ${problem.code}: ${problem.msg}');
      }
    }
    rethrow;
  } catch (e) {
    print('❌ Failed to send mail: $e');
    rethrow;
  }
}