inbound

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package inbound is the SMTP server on port 25: it receives mail for lfr's domains, refuses abuse as early and cheaply as possible, authenticates and scores what remains, and hands accepted messages to the engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CRLF

func CRLF(raw []byte) []byte

CRLF turns every bare LF and bare CR into CRLF, so a message cannot carry line endings that a later hop reads differently (RFC 5321 §2.3.8; the SMTP smuggling class of attacks), and parsing sees one header boundary.

Types

type Envelope

type Envelope struct {
	From    string
	Rcpts   []string
	Raw     []byte // with lfr's Received and Authentication-Results fields
	Parsed  *msg.Parsed
	Auth    mailauth.Result
	Verdict spam.Verdict
	IP      net.IP
	Helo    string
	TLS     bool
}

Envelope is an accepted message.

type Server

type Server struct {
	Hostname func(ctx context.Context) string
	Config   config.Config
	DNS      dnsx.Resolver
	DNSBL    *dnsbl.Checker
	Log      *slog.Logger
	TLS      *tls.Config
	Now      func() time.Time

	// Accept decides at RCPT time whether lfr takes mail for an address.
	Accept func(ctx context.Context, rcpt string) (bool, error)
	// System reports addresses lfr handles itself (bounces, reports), which skip spam scoring.
	System func(rcpt string) bool
	// Classify scores a message; KnownContact reports earlier correspondence.
	Classify     func(ctx context.Context, in spam.Input) spam.Verdict
	KnownContact func(ctx context.Context, email string) bool
	// Local reports whether lfr serves a domain.
	Local func(ctx context.Context, domain string) bool
	// Deliver stores or processes an accepted message.
	Deliver func(ctx context.Context, e *Envelope) error
	// contains filtered or unexported fields
}

Server receives mail.

func (*Server) NewSession

func (s *Server) NewSession(c *smtp.Conn) (smtp.Session, error)

NewSession implements smtp.Backend.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, l net.Listener) error

Serve accepts connections on l until ctx ends.

Jump to

Keyboard shortcuts

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