mirror of
https://github.com/emersion/go-smtp
synced 2026-07-10 21:58:36 +00:00
This allows backend to return an error on MAIL FROM or RCPT TO (https://github.com/emersion/go-smtp/issues/22). backendutil.TransformBackend is removed for reasons explained here: https://github.com/emersion/go-smtp/issues/22#issuecomment-475669004
38 lines
978 B
Go
38 lines
978 B
Go
package smtp
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
)
|
|
|
|
var (
|
|
ErrAuthRequired = errors.New("Please authenticate first")
|
|
ErrAuthUnsupported = errors.New("Authentication not supported")
|
|
)
|
|
|
|
// A SMTP server backend.
|
|
type Backend interface {
|
|
// Authenticate a user. Return smtp.ErrAuthUnsupported if you don't want to
|
|
// support this.
|
|
Login(state *ConnectionState, username, password string) (Session, error)
|
|
|
|
// Called if the client attempts to send mail without logging in first.
|
|
// Return smtp.ErrAuthRequired if you don't want to support this.
|
|
AnonymousLogin(state *ConnectionState) (Session, error)
|
|
}
|
|
|
|
type Session interface {
|
|
// Discard currently processed message.
|
|
Reset()
|
|
|
|
// Free all resources associated with session.
|
|
Logout() error
|
|
|
|
// Set return path for currently processed message.
|
|
Mail(from string) error
|
|
// Add recipient for currently processed message.
|
|
Rcpt(to string) error
|
|
// Set currently processed message contents and send it.
|
|
Data(r io.Reader) error
|
|
}
|