Documentation ¶
Overview ¶
Package smtpd implements the SMTP server protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Debug can be set to true to print SMTP traces to the default Logger in package log.
var DefaultHostname, _ = os.Hostname()
DefaultHostname is used in the banner greeting when Server#hostname is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface { // Connect is called after connecting Connect(source string) error // Hello is called after EHLO/HELO Hello(hostname string) error // Authenticate is called after AUTH //Authenticate(identity, username, password_or_response string) error AuthUser(identity, username string) (password string, err error) // Sender is called after MAIL FROM Sender(address string) error // Recipient is called after RCPT TO Recipient(address string) error // Message is called after DATA. The reader returns the message data // after dot unstuffing. The final ".\r\n" is not included in the data. // When the complete message is consumed io.EOF is returned. It's not // required to consume all data. Any remaining data will be discarded // after Message() returns and the reader will become invalid. Message(reader io.Reader) error }
Handler should be implemented by the application for handling SMTP command parameters and message data on a connection.
Each member can return an error to reject the command or to indicate processing failure. If the error text starts with a three digit status code, then the error text is returned as-is in the SMTP reply. If the error does not start with three digits, then "451 Requested action aborted: " is returned in the SMTP reply with the error text appended.
type Server ¶
type Server struct { // Hostname to use in responses Hostname string // Set to enable STARTTLS // must include at least one certificate or else set GetCertificate TLSConfig *tls.Config // Set to enable PIPELINING Pipelining bool }
Server represents an SMTP server configuration.
func (*Server) ServeSMTP ¶
ServeSMTP should be called by the application for each incoming connection.
The application provides a new instance of the Handler interface that can be used to process command parameters and read the message data.
The application should close the connection after ServeSMTP returns.