conn

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package conn dials and authenticates IMAP and SMTP connections.

Index

Constants

This section is empty.

Variables

View Source
var ClientVersion = "dev"

ClientVersion is sent in the IMAP ID command; release builds set it.

View Source
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 DialIMAP

func DialIMAP(ctx context.Context, e Endpoint) (*imapclient.Client, error)

DialIMAP connects to e and logs in.

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

func DialSMTP(ctx context.Context, e Endpoint) (*smtp.Client, error)

DialSMTP connects to e and authenticates with PLAIN, or XOAUTH2 when e has an AccessToken.

func NewXOAuth2Client

func NewXOAuth2Client(username, token string) sasl.Client

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 "".

type Security

type Security string

Security selects the transport protection of a connection.

const (
	TLS      Security = "tls"
	StartTLS Security = "starttls"
	None     Security = "none"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL