smtpsrv

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package smtpsrv implements chasquid's SMTP server and connection handler.

Index

Constants

This section is empty.

Variables

View Source
var (
	ModeSMTP          = SocketMode{IsSubmission: false, TLS: false}
	ModeSubmission    = SocketMode{IsSubmission: true, TLS: false}
	ModeSubmissionTLS = SocketMode{IsSubmission: true, TLS: true}
)

Valid socket modes.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn represents an incoming SMTP connection.

func (*Conn) AUTH

func (c *Conn) AUTH(params string) (code int, msg string)

AUTH SMTP command handler.

func (*Conn) Close

func (c *Conn) Close()

Close the connection.

func (*Conn) DATA

func (c *Conn) DATA(params string) (code int, msg string)

DATA SMTP command handler.

func (*Conn) EHLO

func (c *Conn) EHLO(params string) (code int, msg string)

EHLO SMTP command handler.

func (*Conn) EXPN

func (c *Conn) EXPN(params string) (code int, msg string)

EXPN SMTP command handler.

func (*Conn) HELO

func (c *Conn) HELO(params string) (code int, msg string)

HELO SMTP command handler.

func (*Conn) HELP

func (c *Conn) HELP(params string) (code int, msg string)

HELP SMTP command handler.

func (*Conn) Handle

func (c *Conn) Handle()

Handle implements the main protocol loop (reading commands, sending replies).

func (*Conn) MAIL

func (c *Conn) MAIL(params string) (code int, msg string)

MAIL SMTP command handler.

func (*Conn) NOOP

func (c *Conn) NOOP(params string) (code int, msg string)

NOOP SMTP command handler.

func (*Conn) RCPT

func (c *Conn) RCPT(params string) (code int, msg string)

RCPT SMTP command handler.

func (*Conn) RSET

func (c *Conn) RSET(params string) (code int, msg string)

RSET SMTP command handler.

func (*Conn) STARTTLS

func (c *Conn) STARTTLS(params string) (code int, msg string)

STARTTLS SMTP command handler.

func (*Conn) VRFY

func (c *Conn) VRFY(params string) (code int, msg string)

VRFY SMTP command handler.

type Server

type Server struct {
	// Main hostname, used for display only.
	Hostname string

	// Maximum data size.
	MaxDataSize int64

	// Use HAProxy on incoming connections.
	HAProxyEnabled bool

	// Path to the hooks.
	HookPath string
	// contains filtered or unexported fields
}

Server represents an SMTP server instance.

func NewServer

func NewServer() *Server

NewServer returns a new empty Server.

func (*Server) AddAddr

func (s *Server) AddAddr(a string, m SocketMode)

AddAddr adds an address for the server to listen on.

func (*Server) AddAliasesFile

func (s *Server) AddAliasesFile(domain, f string) error

AddAliasesFile adds an aliases file for the given domain.

func (*Server) AddCerts

func (s *Server) AddCerts(certPath, keyPath string) error

AddCerts (TLS) to the server.

func (*Server) AddDomain

func (s *Server) AddDomain(d string)

AddDomain adds a local domain to the server.

func (*Server) AddListeners

func (s *Server) AddListeners(ls []net.Listener, m SocketMode)

AddListeners adds listeners for the server to listen on.

func (*Server) AddUserDB

func (s *Server) AddUserDB(domain string, db *userdb.DB)

AddUserDB adds a userdb.DB instance as backend for the domain.

func (*Server) InitQueue

func (s *Server) InitQueue(path string, localC, remoteC courier.Courier)

InitQueue initializes the queue.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe()

ListenAndServe on the addresses and listeners that were previously added. This function will not return.

func (*Server) Reload added in v1.13.0

func (s *Server) Reload()

func (*Server) SetAliasesConfig

func (s *Server) SetAliasesConfig(suffixSep, dropChars string)

SetAliasesConfig sets the aliases configuration options.

func (*Server) SetAuthFallback

func (s *Server) SetAuthFallback(be auth.Backend)

SetAuthFallback sets the authentication backend to use as fallback.

func (*Server) SetDomainInfo added in v1.13.0

func (s *Server) SetDomainInfo(dinfo *domaininfo.DB)

SetDomainInfo sets the domain info database to use.

type SocketMode

type SocketMode struct {
	// Is this mode submission?
	IsSubmission bool

	// Is this mode TLS-wrapped? That means that we don't use STARTTLS, the
	// connection is directly established over TLS (like HTTPS).
	TLS bool
}

SocketMode represents the mode for a socket (listening or connection). We keep them distinct, as policies can differ between them.

func (SocketMode) String

func (mode SocketMode) String() string

Jump to

Keyboard shortcuts

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