Documentation
¶
Overview ¶
Package smtp implements an SMTP server for Freemail.
Index ¶
Constants ¶
const ( DefaultPort = 3025 DefaultHostname = "localhost" ReadTimeout = 5 * time.Minute WriteTimeout = 5 * time.Minute MaxMessageSize = 10 * 1024 * 1024 // 10MB MaxRecipients = 100 )
Server configuration
Variables ¶
This section is empty.
Functions ¶
func ParseHeaders ¶
func ParseHeaders(data []byte) (textproto.MIMEHeader, []byte, error)
ParseHeaders parses raw headers into a textproto.MIMEHeader
Types ¶
type Authenticator ¶
type Authenticator interface {
// Authenticate validates username and password
Authenticate(username, password string) (bool, error)
// GetAccountID returns the account ID for a username
GetAccountID(username string) string
}
Authenticator interface for validating credentials
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a client SMTP connection
func NewConnection ¶
func NewConnection(conn net.Conn, server *Server) *Connection
NewConnection creates a new SMTP connection
type FreemailAuthenticator ¶
type FreemailAuthenticator struct {
// contains filtered or unexported fields
}
FreemailAuthenticator authenticates users against Freemail accounts
func NewFreemailAuthenticator ¶
func NewFreemailAuthenticator(am *freemail.AccountManager) *FreemailAuthenticator
NewFreemailAuthenticator creates a new Freemail authenticator
func (*FreemailAuthenticator) Authenticate ¶
func (a *FreemailAuthenticator) Authenticate(username, password string) (bool, error)
Authenticate validates username and password
func (*FreemailAuthenticator) GetAccountID ¶
func (a *FreemailAuthenticator) GetAccountID(username string) string
GetAccountID returns the account ID for a username
type FreemailHandler ¶
type FreemailHandler struct {
// contains filtered or unexported fields
}
FreemailHandler handles messages for Freemail delivery
func NewFreemailHandler ¶
func NewFreemailHandler(am *freemail.AccountManager, tm *freemail.TransportManager, storage *freemail.Storage) *FreemailHandler
NewFreemailHandler creates a new Freemail message handler
func (*FreemailHandler) HandleMessage ¶
func (h *FreemailHandler) HandleMessage(from string, to []string, data []byte) error
HandleMessage processes a submitted email message
type MessageHandler ¶
type MessageHandler interface {
// HandleMessage processes a submitted email message
HandleMessage(from string, to []string, data []byte) error
}
MessageHandler interface for handling submitted messages
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an SMTP server
func (*Server) GetAuthenticator ¶
func (s *Server) GetAuthenticator() Authenticator
GetAuthenticator returns the authenticator
func (*Server) GetHandler ¶
func (s *Server) GetHandler() MessageHandler
GetHandler returns the message handler
func (*Server) GetHostname ¶
GetHostname returns the server hostname
func (*Server) SetAuthenticator ¶
func (s *Server) SetAuthenticator(auth Authenticator)
SetAuthenticator sets the authenticator
func (*Server) SetHandler ¶
func (s *Server) SetHandler(handler MessageHandler)
SetHandler sets the message handler
type SessionState ¶
type SessionState int
SessionState represents the state of an SMTP session
const ( StateInit SessionState = iota StateGreeted StateAuthenticated StateMailFrom StateRcptTo StateData )