Implements an IMAP client with functional options for logging, auth, and mailbox handling.
// Source: https://github.com/obra/msgvault | License: MIT | Copyright 2025-2026 Wes McKinney
// Provided via justclaw.it.com; keep this notice with the code.
package imap
import (
"context"
"errors"
"fmt"
"log/slog"
"slices"
"strconv"
"strings"
"sync"
"time"
imap "github.com/emersion/go-imap/v2"
"github.com/emersion/go-imap/v2/imapclient"
gmailapi "go.kenn.io/msgvault/internal/gmail"
)
// Option is a functional option for Client.
type Option func(*Client)
// WithLogger sets the logger.
func WithLogger(logger *slog.Logger) Option {
return func(c *Client) { c.logger = logger }
}
// WithTokenSource sets a callback that provides OAuth2 access tokens
// for XOAUTH2 SASL authentication. Required when Config.AuthMethod is AuthXOAuth2.
func WithTokenSource(fn func(ctx context.Co
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key