smtpdgrip

package module
v0.0.0-...-46008fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

README

smtpd-grip

A copy of the https://github.com/mhale/smtpd repository with GRIP support.

Documentation

Overview

Package smtpd implements a basic SMTP server.

Index

Constants

View Source
const (
	ColorReset  = "\033[0m"
	ColorRed    = "\033[31m"
	ColorGreen  = "\033[32m"
	ColorYellow = "\033[33m"
	ColorBlue   = "\033[34m"
	ColorPurple = "\033[35m"
	ColorCyan   = "\033[36m"
	ColorWhite  = "\033[37m"
)

Variables

View Source
var (
	// Debug `true` enables verbose logging.
	Debug = false
)
View Source
var ErrServerClosed = errors.New("Server has been closed")

Functions

func ListenAndServe

func ListenAndServe(addr string, handler Handler, appname string, hostname string) error

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

type Handler func(remoteAddr net.Addr, from string, to []string, data []byte) error

Handler function called upon successful receipt of an email.

type HandlerRcpt

type HandlerRcpt func(remoteAddr net.Addr, from string, to string) bool

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 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.
	Handler      Handler
	HandlerRcpt  HandlerRcpt
	Hostname     string
	LogRead      LogFunc
	LogWrite     LogFunc
	MaxSize      int // Maximum message size allowed, in bytes
	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.
	// contains filtered or unexported fields
}

Server is an SMTP server.

func (*Server) Close

func (srv *Server) Close() error

Close - closes the connection without waiting

func (*Server) ConfigureTLS

func (srv *Server) ConfigureTLS(certFile string, keyFile string) error

ConfigureTLS creates a TLS configuration from certificate and key files.

func (*Server) ConfigureTLSWithPassphrase

func (srv *Server) ConfigureTLSWithPassphrase(
	certFile string,
	keyFile string,
	passphrase string,
) error

ConfigureTLSWithPassphrase creates a TLS configuration from a certificate, an encrypted key file and the associated passphrase:

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

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.

func (*Server) Serve

func (srv *Server) Serve(ln net.Listener) error

Serve creates a new SMTP session after a network connection is established.

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

Shutdown - waits for current sessions to complete before closing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL