Documentation
¶
Overview ¶
Package conn dials and authenticates IMAP and SMTP connections.
Index ¶
- Variables
- func DialIMAP(ctx context.Context, e Endpoint) (*imapclient.Client, error)
- func DialIMAPAbortable(ctx context.Context, e Endpoint, h *imapclient.UnilateralDataHandler) (*imapclient.Client, func(), error)
- func DialSMTP(ctx context.Context, e Endpoint) (*smtp.Client, error)
- func NewXOAuth2Client(username, token string) sasl.Client
- type Endpoint
- type FailureKind
- type Security
Constants ¶
This section is empty.
Variables ¶
var ClientVersion = "dev"
ClientVersion is sent in the IMAP ID command; release builds set it.
var ErrAuthFailed = errors.New("authentication failed")
ErrAuthFailed means the server rejected the credentials. Server text is never included, because servers may echo the submitted password.
Functions ¶
func DialIMAPAbortable ¶
func DialIMAPAbortable(ctx context.Context, e Endpoint, h *imapclient.UnilateralDataHandler) (*imapclient.Client, func(), error)
DialIMAPAbortable is DialIMAP that also returns abort, which closes the network connection at once. Unlike Client.Close it does not wait for a response literal being read, so it can cut off a download. h, if not nil, receives unsolicited server updates (IDLE).
func DialSMTP ¶
DialSMTP connects to e and authenticates with PLAIN, or XOAUTH2 when e has an AccessToken.
func NewXOAuth2Client ¶
NewXOAuth2Client returns a SASL XOAUTH2 client (Google and Microsoft IMAP/SMTP).
Types ¶
type Endpoint ¶
type Endpoint struct {
Host string
Port int
Security Security
Username, Password string
AccessToken string
}
Endpoint describes one server and the credentials to use on it. A non-empty AccessToken selects XOAUTH2 and Password is ignored.
type FailureKind ¶
type FailureKind string
FailureKind is the broad cause of a failed dial, for diagnostics.
const ( FailureDNS FailureKind = "dns" FailureConnect FailureKind = "connect" FailureTimeout FailureKind = "timeout" FailureTLS FailureKind = "tls" FailureAuth FailureKind = "auth" FailureProtocol FailureKind = "protocol" )
func Classify ¶
func Classify(err error) FailureKind
Classify maps an error from DialIMAP or DialSMTP to a FailureKind; nil gives "".