Documentation ¶
Overview ¶
Package smtp provides an SMTP server for receiving mail.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { Start() (toClient string, err error) Auth(user, fromClient string) (ok bool) }
func CramAuthenticator ¶
func CramAuthenticator(a func(string) string) Authenticator
type Handler ¶
type Handler func(Message)
A Handler receives Messages when transactions are completed.
Example ¶
var logger = func(message Message) { log.Printf("Recieved message from %s\n%s\n", message.Sender, message.Data) } s.Handle(logger)
Output:
type Server ¶
type Server struct { CramAuthenticator func(string) string // contains filtered or unexported fields }
Example ¶
s, err := Listen(":25", "mx.test.local") if err != nil { panic(err) } defer s.Close() s.Handle(func(message Message) { // ... })
Output:
func Listen ¶
Listen creates a new Server listening at the local network address laddr and will announce itself to new connections with the name given.
func (*Server) Expand ¶
Expand registers the Expander to be used when an EXPN command is issued to the Server. If an Expander was previously registered it is overwritten.
type User ¶
type User struct {
Name, Addr string
}
User represents an account that can receive mail with a name and address usually formatted as, e.g., "John Doe <john.doe@example.com>".
type Verifier ¶
A Verifier verifies whether its argument represents a user or email address on the system, and if so returns the details as a User; otherwise an empty User is returned.
Example ¶
var users = []User{ {"John Doe", "john.doe@example.com"}, {"Jane Doe", "jane.doe@example.com"}, } s.Verify(func(arg string) User { for _, user := range users { if user.Name == arg || user.Addr == arg { return user } } return User{} })
Output: