Documentation ¶
Overview ¶
Package smtpd implements an SMTP server. Hooks are provided to customize its behavior.
Index ¶
- type BasicEnvelope
- func (e *BasicEnvelope) AddMailboxId(mailboxId int) error
- func (e *BasicEnvelope) AddRecipient(rcpt MailAddress) error
- func (e *BasicEnvelope) AddSender(from MailAddress) error
- func (e *BasicEnvelope) BeginData() error
- func (e *BasicEnvelope) Close() error
- func (e *BasicEnvelope) Write(line []byte) error
- type Connection
- type Envelope
- type MailAddress
- type SMTPError
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicEnvelope ¶
type BasicEnvelope struct { MailboxID int From MailAddress Rcpts []MailAddress MailBody []byte }
func (*BasicEnvelope) AddMailboxId ¶
func (e *BasicEnvelope) AddMailboxId(mailboxId int) error
func (*BasicEnvelope) AddRecipient ¶
func (e *BasicEnvelope) AddRecipient(rcpt MailAddress) error
func (*BasicEnvelope) AddSender ¶
func (e *BasicEnvelope) AddSender(from MailAddress) error
func (*BasicEnvelope) BeginData ¶
func (e *BasicEnvelope) BeginData() error
func (*BasicEnvelope) Close ¶
func (e *BasicEnvelope) Close() error
func (*BasicEnvelope) Write ¶
func (e *BasicEnvelope) Write(line []byte) error
type Connection ¶
Connection is implemented by the SMTP library and provided to callers customizing their own Servers.
type Envelope ¶
type Envelope interface { AddMailboxId(mailboxId int) error AddSender(from MailAddress) error AddRecipient(rcpt MailAddress) error BeginData() error Write(line []byte) error Close() error }
type MailAddress ¶
type MailAddress interface { Email() string // email address, as provided Hostname() string // canonical hostname, lowercase Username() string // clear username, without "+" part, lowercase }
MailAddress is defined by
type Server ¶
type Server struct { Addr string // TCP address to listen on, ":2525" if empty Hostname string // optional Hostname to announce; "" to use system hostname ReadTimeout time.Duration // optional read timeout WriteTimeout time.Duration // optional write timeout TLSconfig *tls.Config // tls config ServerConfig *config.Config // OnNewConnection, if non-nil, is called on new connections. // If it returns non-nil, the connection is closed. OnNewConnection func(c Connection) error // OnNewMail must be defined and is called when a new message beings. // (when a MAIL FROM line arrives) OnNewMail func(c Connection, from MailAddress) (Envelope, error) }
Server is an SMTP server.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the TCP network address srv.Addr and then calls Serve to handle requests on incoming connections. If srv.Addr is blank, ":25" is used.
Click to show internal directories.
Click to hide internal directories.