Documentation
¶
Overview ¶
Package smtp provides SMTP client for sending emails.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPoolClosed = errors.New("pool is closed")
ErrPoolClosed is returned when Get is called on a closed pool.
var ErrXOAuth2Challenge = errors.New("unexpected XOAUTH2 server challenge")
ErrXOAuth2Challenge indicates an unexpected server challenge during XOAUTH2.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps SMTP operations with rate limiting.
func (*Client) RateLimitInfo ¶
RateLimitInfo returns current rate limit state.
type Operations ¶
type Operations interface {
Send(ctx context.Context, accountID string, req *SendRequest) error
AccountEmail(accountID string) (string, error)
DefaultAccountID() string
}
Operations defines the SMTP operations interface. Tool handlers accept this interface instead of concrete *Pool, enabling mock injection for unit tests.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages SMTP clients for multiple accounts.
func (*Pool) AccountEmail ¶
AccountEmail returns the email address for the given account.
func (*Pool) Close ¶
func (p *Pool) Close()
Close rejects new operations. SMTP connections are short-lived (connect per Send), so there are no persistent connections to drain.
func (*Pool) DefaultAccountID ¶
DefaultAccountID returns the configured default account ID.
func (*Pool) Get ¶
Get returns an SMTP client for the given account. Unlike IMAP Pool.Get(), this method does NOT need to release the mutex during client creation because SMTP clients are lightweight structs — no network I/O happens here. The actual TCP+TLS connection is deferred to Send() via DialAndSend(). Holding the lock for the duration is safe and correct. Returns ErrPoolClosed if the pool is shutting down.
type SendAttachment ¶
type SendAttachment struct {
Path string // absolute file path (file-based)
Filename string // display name
Data []byte // raw content (in-memory, e.g. from IMAP fetch)
}
SendAttachment represents a file attachment for sending. Set Path for file-based attachments (email_send), or Data for in-memory attachments (email_forward). If both are set, Data takes precedence.