From 2040fc1885ca4b4bea07d91e9fc6a0aaebfe7133 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Tue, 9 May 2023 17:19:42 +0200 Subject: imap: use delimiter from server To accommodate servers that use a delimiter other than "/" ("." being a common alternative), the delimiter is fetched from the server when connecting. Signed-off-by: Moritz Poldrack Acked-by: Robin Jarry --- worker/imap/connect.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'worker/imap/connect.go') diff --git a/worker/imap/connect.go b/worker/imap/connect.go index 6f341753..f0ed8043 100644 --- a/worker/imap/connect.go +++ b/worker/imap/connect.go @@ -94,6 +94,17 @@ func (w *IMAPWorker) connect() (*client.Client, error) { return nil, err } + info := make(chan *imap.MailboxInfo, 1) + if err := c.List("", "", info); err != nil { + return nil, fmt.Errorf("failed to retrieve delimiter: %w", err) + } + mailboxinfo := <-info + w.delimiter = mailboxinfo.Delimiter + if w.delimiter == "" { + // just in case some implementation does not follow standards + w.delimiter = "/" + } + return c, nil } -- cgit