feat(email): add 'Test connection' to incoming mail + tidy IMAP label
- emailIntakeService.testConnection(): logs in, opens the configured folder, reports message/unread counts (non-destructive). Accepts current form creds so it works before saving; masked password falls back to stored. - route POST /admin/email/incoming-config/test - IMAP card: 'Test connection' button beside Save; toast shows folder + counts - capitalize 'IMAP Host' label to match 'SMTP Host' Note: incoming uses IMAP (receiving) vs outgoing SMTP (sending) — genuinely different servers/credentials, hence the distinct field set (Folder; no From).
This commit is contained in:
@@ -95,6 +95,13 @@ export interface ImapFolder {
|
||||
specialUse: string | null;
|
||||
}
|
||||
|
||||
export interface ImapTestResult {
|
||||
ok: boolean;
|
||||
folder: string;
|
||||
messages: number;
|
||||
unseen: number;
|
||||
}
|
||||
|
||||
export interface ReceivedEmail {
|
||||
id: number;
|
||||
message_id: string | null;
|
||||
@@ -138,6 +145,11 @@ export const emailService = {
|
||||
const response = await api.post<{ folders: ImapFolder[] }>('/admin/email/incoming-config/folders', config || {});
|
||||
return response.data.folders;
|
||||
},
|
||||
// Test the IMAP connection: opens the configured folder, reports counts.
|
||||
async testIncoming(config?: Partial<IncomingMailConfig>): Promise<ImapTestResult> {
|
||||
const response = await api.post<ImapTestResult>('/admin/email/incoming-config/test', config || {});
|
||||
return response.data;
|
||||
},
|
||||
async listReceived(params: { page?: number; pageSize?: number } = {}): Promise<ReceivedEmailsResponse> {
|
||||
const response = await api.get<ReceivedEmailsResponse>('/admin/email/received', { params });
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user