Documentation
¶
Overview ¶
Package smtpd is the SMTP daemon
Package smtpd implements a basic SMTP server.
This is a modified version of https://github.com/mhale/smtpd to add support for unix sockets and Mailpit Chaos.
Index ¶
- Variables
- func Listen() error
- func ListenAndServe(addr string, handler Handler, appName string, hostname string) error
- func ListenAndServeTLS(addr string, certFile string, keyFile string, handler Handler, appName string, ...) error
- func LoginAuth(username, password string) smtp.Auth
- func Relay(from string, to []string, msg []byte) error
- func SaveToDatabase(origin net.Addr, from string, to []string, data []byte, smtpUser *string) (string, error)
- type AuthHandler
- type Handler
- type HandlerRcpt
- type LogFunc
- type MsgIDHandler
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( // Debug `true` enables verbose logging. Debug = false )
var ( // DisableReverseDNS allows rDNS to be disabled DisableReverseDNS bool )
var ErrServerClosed = errors.New("Server has been closed")
ErrServerClosed is the default message when a server closes a connection
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections.
func ListenAndServeTLS ¶
func ListenAndServeTLS(addr string, certFile string, keyFile string, handler Handler, appName string, hostname string) error
ListenAndServeTLS listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections. Connections may be upgraded to TLS if the client requests it.
Types ¶
type AuthHandler ¶
type AuthHandler func(remoteAddr net.Addr, mechanism string, username []byte, password []byte, shared []byte) (bool, error)
AuthHandler function called when a login attempt is performed. Returns true if credentials are correct.
type Handler ¶
Handler function called upon successful receipt of an email. Results in a "250 2.0.0 Ok: queued" response.
type HandlerRcpt ¶
HandlerRcpt function called on RCPT. Return accept status.
type LogFunc ¶
type LogFunc func(remoteIP, verb, line string)
LogFunc is a function capable of logging the client-server communication.
type MsgIDHandler ¶
type MsgIDHandler func(remoteAddr net.Addr, from string, to []string, data []byte, username *string) (string, error)
MsgIDHandler function called upon successful receipt of an email. Returns a message ID. Results in a "250 2.0.0 Ok: queued as <message-id>" response.
type Server ¶
type Server struct {
Addr string // TCP address to listen on, defaults to ":25" (all addresses, port 25) if empty
AppName string
AuthHandler AuthHandler
AuthMechs map[string]bool // Override list of allowed authentication mechanisms. Currently supported: LOGIN, PLAIN, CRAM-MD5. Enabling LOGIN and PLAIN will reduce RFC 4954 compliance.
AuthRequired bool // Require authentication for every command except AUTH, EHLO, HELO, NOOP, RSET or QUIT as per RFC 4954. Ignored if AuthHandler is not configured.
DisableReverseDNS bool // Disable reverse DNS lookups, enforces "unknown" hostname
Handler Handler
HandlerRcpt HandlerRcpt
Hostname string
LogRead LogFunc
LogWrite LogFunc
MaxSize int // Maximum message size allowed, in bytes
MaxRecipients int // Maximum number of recipients, defaults to 100.
MsgIDHandler MsgIDHandler
IgnoreRejectedRecipients bool // Accept emails to rejected recipients with 2xx response but silently drop them
Timeout time.Duration
TLSConfig *tls.Config
TLSListener bool // Listen for incoming TLS connections only (not recommended as it may reduce compatibility). Ignored if TLS is not configured.
TLSRequired bool // Require TLS for every command except NOOP, EHLO, STARTTLS, or QUIT as per RFC 3207. Ignored if TLS is not configured.
Protocol string // Default tcp, supports unix
SocketPerm fs.FileMode // if using Unix socket, socket permissions
XClientAllowed []string // List of XCLIENT allowed IP addresses
// contains filtered or unexported fields
}
Server is an SMTP server.
func (*Server) ConfigureTLS ¶
ConfigureTLS creates a TLS configuration from certificate and key files.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the either a TCP network address srv.Addr or alternatively a Unix socket. and then calls Serve to handle requests on incoming connections. If srv.Addr is blank, ":25" is used.