Documentation ¶
Index ¶
- Variables
- type Auth
- type AuthCramMd5
- type AuthExtension
- type AuthPlain
- type AuthUser
- type Conn
- func (c *Conn) EndTX() error
- func (c *Conn) ReadData() (string, error)
- func (c *Conn) ReadLine() (string, error)
- func (c *Conn) ReadSMTP() (string, string, error)
- func (c *Conn) Reset()
- func (c *Conn) StartTX(from *mail.Address) error
- func (c *Conn) WriteEHLO(message string) error
- func (c *Conn) WriteOK() error
- func (c *Conn) WriteSMTP(code int, message string) error
- type Extension
- type MessageHandler
- type SMTPError
- type Server
- func (s *Server) Address() string
- func (s *Server) Close()
- func (s *Server) Disable(verbs ...string)
- func (s *Server) Enable(verbs ...string)
- func (s *Server) Extend(verb string, extension Extension) error
- func (s *Server) GetAddressArg(argName string, args string) (*mail.Address, error)
- func (s *Server) Greeting(conn *Conn) string
- func (s *Server) HandleSMTP(conn *Conn) error
- func (s *Server) ListenAndServe(addr string) error
- func (s *Server) SetHelp(message string) error
- func (s *Server) UseAuth(auth Extension)
- func (s *Server) UseTLS(cert, key string) error
- type SimpleAuthFunc
- type SimpleExtension
Constants ¶
This section is empty.
Variables ¶
var ErrAuthCancelled = &SMTPError{501, errors.New("Cancelled")}
var ErrAuthFailed = &SMTPError{535, errors.New("Authentication credentials invalid")}
var ErrRequiresTLS = &SMTPError{538, errors.New("Encryption required for requested authentication mechanism")}
var ErrTransaction = &SMTPError{501, errors.New("Transaction unsuccessful")}
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
Mechanisms map[string]AuthExtension
}
type AuthCramMd5 ¶
func (*AuthCramMd5) CheckResponse ¶
func (a *AuthCramMd5) CheckResponse(response string, challenge []byte) (AuthUser, bool)
Note: This is currently very weak & requires storing of the user's password in plaintext one good alternative is to do the HMAC manually and expose handlers for pre-processing the password MD5s
func (*AuthCramMd5) Handle ¶
func (a *AuthCramMd5) Handle(conn *Conn, params string) (AuthUser, error)
Handles the negotiation of an AUTH CRAM-MD5 request https://en.wikipedia.org/wiki/CRAM-MD5 http://www.samlogic.net/articles/smtp-commands-reference-auth.htm
type AuthExtension ¶
http://tools.ietf.org/html/rfc4422#section-3.1 https://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer
type AuthPlain ¶
type AuthPlain struct {
Auth SimpleAuthFunc
}
type Conn ¶
type Conn struct { // Conn is primarily a wrapper around a net.Conn object net.Conn // Track some mutable for this connection IsTLS bool Errors []error User AuthUser FromAddr *mail.Address ToAddr []*mail.Address // Configuration options MaxSize int ReadTimeout int64 WriteTimeout int64 // contains filtered or unexported fields }
func (*Conn) ReadSMTP ¶
ReadSMTP pulls a single SMTP command line (ending in a carriage return + newline)
func (*Conn) WriteEHLO ¶
WriteEHLO writes an EHLO line, see https://tools.ietf.org/html/rfc2821#section-4.1.1.1
type MessageHandler ¶
MessageHandler functions handle application of business logic to the inbound message
type SMTPError ¶
type SMTPError struct {
// contains filtered or unexported fields
}
SMTPError is an error + SMTP response code
type Server ¶
type Server struct { Name string TLSConfig *tls.Config ServerName string // MaxSize of incoming message objects, zero for no cap otherwise // larger messages are thrown away MaxSize int // MaxConn limits the number of concurrent connections being handled MaxConn int // MaxCommands is the maximum number of commands a server will accept // from a single client before terminating the session MaxCommands int // RateLimiter gets called before proceeding through to message handling RateLimiter func(*Conn) bool // Handler is the handoff function for messages Handler MessageHandler // Auth is an authentication-handling extension Auth Extension // Extensions is a map of server-specific extensions & overrides, by verb Extensions map[string]Extension // Disabled features Disabled map[string]bool // help message to display in response to a HELP request Help string // Logger to print out status info Logger email.Logger // contains filtered or unexported fields }
func (*Server) GetAddressArg ¶
func (*Server) HandleSMTP ¶
func (*Server) ListenAndServe ¶
ListenAndServe starts listening for SMTP commands at the supplied TCP address