feat(imapx): connect, endpoint test, login test with folder listing

This commit is contained in:
2026-07-01 17:20:03 +07:00
parent 37cb8ba076
commit 0451b79c64
5 changed files with 154 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package imapx
import (
"context"
)
func TestLogin(ctx context.Context, ep Endpoint, login, pass string) ([]string, error) {
c, err := Connect(ctx, ep)
if err != nil {
return nil, err
}
defer func() { _ = c.Logout().Wait() }()
if err := c.Login(login, pass).Wait(); err != nil {
return nil, err
}
mboxes, err := c.List("", "*", nil).Collect()
if err != nil {
return nil, err
}
names := make([]string, 0, len(mboxes))
for _, m := range mboxes {
names = append(names, m.Mailbox)
}
return names, nil
}