Documentation
¶
Index ¶
- Constants
- Variables
- func ProbeSMTP(ctx context.Context, rawConfig *OutgoingConfig) error
- type OutgoingConfig
- type OutgoingMail
- func (om *OutgoingMail) Close()
- func (om *OutgoingMail) EffectiveRecipients(email *types.Email) ([]string, error)
- func (om *OutgoingMail) GetConfig() interface{}
- func (om *OutgoingMail) IsAutoRelayEnabled() bool
- func (om *OutgoingMail) RelayMail(email *types.Email, emailPath string, relayTo string, isAutoRelay bool, ...) error
- func (om *OutgoingMail) RelayMailConfirmed(email *types.Email, emailPath string, recipients []string, ...) error
- func (om *OutgoingMail) RelayMailContext(ctx context.Context, email *types.Email, emailPath string, relayTo string, ...) error
- func (om *OutgoingMail) RuntimeReadiness() RuntimeReadiness
- func (om *OutgoingMail) UpdateConfig(config interface{}) error
- type RelayTask
- type RuntimeReadiness
- type TLSMode
Constants ¶
const ( TLSModePlain TLSMode = "plain" TLSModeSTARTTLS TLSMode = "starttls" TLSModeSMTPS TLSMode = "smtps" DefaultConnectTimeout = 10 * time.Second DefaultTLSHandshakeTimeout = 10 * time.Second DefaultAuthTimeout = 10 * time.Second DefaultEnvelopeTimeout = 10 * time.Second DefaultDataTimeout = 30 * time.Second DefaultQuitTimeout = 5 * time.Second )
Variables ¶
var ( // ErrNotConfigured is returned when relay is disabled because no host is set. ErrNotConfigured = errors.New("outgoing mail not configured") // ErrQueueFull is returned when a relay task cannot be queued before the timeout. ErrQueueFull = errors.New("relay queue is full") // ErrClosed is returned when work is submitted after the relay has begun closing. ErrClosed = errors.New("outgoing mail is closed") // ErrConfigChanged is returned when confirmed recipients no longer match // the configuration snapshot used to enqueue delivery. ErrConfigChanged = errors.New("outgoing relay configuration changed") )
var ( ErrSTARTTLSUnsupported = errors.New("outgoing SMTP server does not support STARTTLS") ErrAUTHPlainUnsupported = errors.New("outgoing SMTP server does not advertise AUTH PLAIN") )
Functions ¶
Types ¶
type OutgoingConfig ¶
type OutgoingConfig struct {
Host string
Port int
User string
Password string
Secure bool // Deprecated compatibility alias: true means implicit TLS/SMTPS.
TLSMode TLSMode // plain, starttls, or smtps
InsecureSkipVerify bool
ConnectTimeout string
TLSHandshakeTimeout string
AuthTimeout string
EnvelopeTimeout string
DataTimeout string
QuitTimeout string
AutoRelay bool
AutoRelayAddr string
AllowRules []string // Allow list patterns
DenyRules []string // Deny list patterns
// contains filtered or unexported fields
}
OutgoingConfig represents the configuration for outgoing mail
func (*OutgoingConfig) Validate ¶
func (config *OutgoingConfig) Validate() error
type OutgoingMail ¶
type OutgoingMail struct {
// contains filtered or unexported fields
}
OutgoingMail handles outgoing email relay
func NewOutgoingMail ¶
func NewOutgoingMail(config *OutgoingConfig) *OutgoingMail
NewOutgoingMail creates a new outgoing mail handler
func (*OutgoingMail) Close ¶
func (om *OutgoingMail) Close()
Close rejects new work, lets accepted enqueue operations finish, drains the stable queue, and stops the worker. It is safe to call more than once.
func (*OutgoingMail) EffectiveRecipients ¶
func (om *OutgoingMail) EffectiveRecipients(email *types.Email) ([]string, error)
EffectiveRecipients returns the rule-filtered recipient snapshot currently used for a manual relay to original envelope recipients.
func (*OutgoingMail) GetConfig ¶
func (om *OutgoingMail) GetConfig() interface{}
GetConfig returns the current configuration
func (*OutgoingMail) IsAutoRelayEnabled ¶
func (om *OutgoingMail) IsAutoRelayEnabled() bool
IsAutoRelayEnabled checks if auto relay is enabled
func (*OutgoingMail) RelayMail ¶
func (om *OutgoingMail) RelayMail(email *types.Email, emailPath string, relayTo string, isAutoRelay bool, callback func(error)) error
RelayMail queues an email for relay
func (*OutgoingMail) RelayMailConfirmed ¶
func (om *OutgoingMail) RelayMailConfirmed(email *types.Email, emailPath string, recipients []string, callback func(error)) error
RelayMailConfirmed queues delivery only if the current effective recipients still match the addresses the operator confirmed.
func (*OutgoingMail) RelayMailContext ¶
func (om *OutgoingMail) RelayMailContext(ctx context.Context, email *types.Email, emailPath string, relayTo string, isAutoRelay bool, callback func(error)) error
RelayMailContext queues an email relay that is canceled if the caller's context expires while the task is queued or in progress.
func (*OutgoingMail) RuntimeReadiness ¶ added in v0.11.0
func (om *OutgoingMail) RuntimeReadiness() RuntimeReadiness
func (*OutgoingMail) UpdateConfig ¶
func (om *OutgoingMail) UpdateConfig(config interface{}) error
UpdateConfig atomically replaces the outgoing mail configuration. An empty host disables new submissions; already queued tasks retain the snapshot they were accepted with. Re-enabling starts the worker once, and an empty password explicitly disables authentication for subsequently accepted tasks.
type RelayTask ¶
type RelayTask struct {
Email *types.Email
EmailPath string
RelayTo string // Optional relay address
// ConfirmedRecipients binds a UI confirmation to the exact effective
// recipient list. A nil slice preserves the ordinary rule-based behavior.
ConfirmedRecipients []string
IsAutoRelay bool
Callback func(error)
Context context.Context
// contains filtered or unexported fields
}
RelayTask represents a task to relay an email
type RuntimeReadiness ¶ added in v0.11.0
type RuntimeReadiness struct {
Enabled bool `json:"enabled"`
Closed bool `json:"closed"`
Workers int32 `json:"workers"`
Queued int `json:"queued"`
Capacity int `json:"capacity"`
}
RuntimeReadiness describes queue capacity and worker lifecycle, without doing network I/O.
func (RuntimeReadiness) Ready ¶ added in v0.11.0
func (status RuntimeReadiness) Ready() bool