// Copyright (c) 2025 H0llyW00dzZ All rights reserved. // // By accessing or using this software, you agree to be bound by the terms // of the License Agreement, which you can find at LICENSE files. package client import ( "fmt" "github.com/emersion/go-imap" ) // ListMailboxes retrieves all available mailboxes for the connected user func (c *IMAPClient) ListMailboxes() ([]string, error) { if c.client == nil { return nil, ErrorsClientIsNotConnected } mailboxes := make(chan *imap.MailboxInfo, 10) done := make(chan error, 1) // Start listing mailboxes go func() { done <- c.client.List("", "*", mailboxes) }() var mailboxNames []string for m := range mailboxes { mailboxNames = append(mailboxNames, m.Name) } if err := <-done; err != nil { return nil, fmt.Errorf("failed to list mailboxes: %v", err) } return mailboxNames, nil }