feat(imapx): connect, endpoint test, login test with folder listing
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user