API fixes (against vendored enough_mail 2.1.7): - listMailboxes() returns List<Mailbox> directly — remove .mailboxes - Use statusMailbox() for unread/total counts per mailbox - fetchMessages(MessageSequence.fromAll(), ...) replaces nonexistent fetchAllMessages(); fetchMessage() takes isUidSequence flag - FetchImapResult.messages are already MimeMessages — no need to re-parse rawData; use msg.decodeTextPlainPart() / decodeTextHtmlPart() - msg.hasAttachments() (method) not msg.body?.hasAttachments (field) - SmtpClient clientDomain = sender domain, not display name; quit() instead of nonexistent disconnect(); STARTTLS wrapped in try/catch - ContentInfo.size is nullable; use a.fileName / a.size getters Other fixes: - main.dart: move sync start to initState, not build() - account_list_screen: remove dead/invalid Riverpod select() code - account_sync_manager: subscribe to account changes; cancel sub on dispose; use Future.any([newMsg, 25-min timeout]) for IDLE - email_repository: add getEmail(id) to interface + impl - email_detail_screen: load header + body together via Future.wait; reply prefills To/Cc/Subject correctly - compose_screen + router: thread prefillCc through Add Linux desktop entry point: - linux/CMakeLists.txt, main.cc, my_application.h/.cc (GTK3 runner) Add flake.lock (generated by nix flake update). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
45 lines
1.4 KiB
Dart
45 lines
1.4 KiB
Dart
import 'package:enough_mail/enough_mail.dart';
|
|
|
|
import '../../core/models/account.dart';
|
|
|
|
/// Opens an authenticated IMAP client for [account].
|
|
Future<ImapClient> connectImap(Account account, String password) async {
|
|
final client = ImapClient(isLogEnabled: false);
|
|
await client.connectToServer(
|
|
account.imapHost,
|
|
account.imapPort,
|
|
isSecure: account.imapSsl,
|
|
);
|
|
await client.login(account.email, password);
|
|
return client;
|
|
}
|
|
|
|
/// Opens an authenticated SMTP client for [account].
|
|
///
|
|
/// Caller is responsible for calling [SmtpClient.quit] when done.
|
|
Future<SmtpClient> connectSmtp(Account account, String password) async {
|
|
// clientDomain is the sending domain advertised in EHLO — use the host part
|
|
// of the sender email, falling back to the SMTP host.
|
|
final atIndex = account.email.lastIndexOf('@');
|
|
final clientDomain =
|
|
atIndex != -1 ? account.email.substring(atIndex + 1) : account.smtpHost;
|
|
|
|
final client = SmtpClient(clientDomain, isLogEnabled: false);
|
|
await client.connectToServer(
|
|
account.smtpHost,
|
|
account.smtpPort,
|
|
isSecure: account.smtpSsl,
|
|
);
|
|
await client.ehlo();
|
|
if (!account.smtpSsl) {
|
|
// Opportunistic TLS on submission port (587)
|
|
try {
|
|
await client.startTls();
|
|
} catch (_) {
|
|
// Server doesn't support STARTTLS — proceed without it.
|
|
}
|
|
}
|
|
await client.authenticate(account.email, password);
|
|
return client;
|
|
}
|