smtpserver

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecurityPass string = "pass"
	SecurityFail string = "fail"
)

Variables

View Source
var (
	ErrHashFail           = errors.New("error while hashing password")
	ErrInvalidDestination = errors.New("invalid destination")
	ErrParsingError       = errors.New("parsing error")
	ErrDomainMisalignment = errors.New("domains not aligned")
	ErrMaxSizeExceeded    = errors.New("maximum message size exceeded")
	ErrValidationError    = errors.New("validation failed")
	ErrMissingDependency  = errors.New("missing dependency")
)
View Source
var (
	ErrSMTPInvalidDestination = &smtp.SMTPError{
		Code:         552,
		EnhancedCode: smtp.EnhancedCode{5, 3, 4},
		Message:      "Invalid destination",
	}

	ErrSMTPServerError = &smtp.SMTPError{
		Code:         552,
		EnhancedCode: smtp.EnhancedCode{5, 3, 4},
		Message:      "Server error",
	}
)

TODO research valid SMTP codes.

Functions

func GetTLSConfig

func GetTLSConfig(c *TLSConfig) (*tls.Config, error)

func LimitedRead

func LimitedRead(r io.Reader, size int64) ([]byte, error)

LimitedRead validates a mail message is no more than 'size' bytes, and returns a new io.Reader containing a copy of the original bytes.

func NewBackend added in v0.1.2

func NewBackend(ss smtp.Backend, tc *tls.Config, port, maxSize int, hostname string) *smtp.Server

Types

type Config added in v0.1.2

type Config struct {
	Hostname string             `json:"hostname,omitempty"`
	Port     int                `json:"port,omitempty"`
	MaxSize  string             `json:"max_size,omitempty"`
	Outbound *smtpclient.Config `json:"outbound,omitempty"`
	TLS      *TLSConfig         `json:"tls,omitempty"`
}

func (*Config) Validate added in v0.1.2

func (c *Config) Validate() error

type EmailSender added in v0.1.12

type EmailSender interface {
	SendMail(*letterbox.ForwardingMessage) error
}

type SMTPService

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

func New added in v0.1.12

func New(
	cfg Config,
	db letterbox.Datastore,
	log logger.Logger,
	bannerBuilder *banner.Builder,
	dkim dkimChecker,
	spf spfChecker,
	client EmailSender,
	mailboxes *letterbox.MailboxService,
	messages *letterbox.MessageService,
	stats *letterbox.MailboxStatsService,
) *SMTPService

func (*SMTPService) AnonymousLogin added in v0.1.2

func (ss *SMTPService) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error)

AnonymousLogin requires clients to authenticate using SMTP AUTH before sending emails.

func (*SMTPService) Login added in v0.1.2

func (ss *SMTPService) Login(state *smtp.ConnectionState, username, password string) (smtp.Session, error)

Login handles a login command with username and password.

func (*SMTPService) Name

func (ss *SMTPService) Name() string

func (*SMTPService) Start

func (ss *SMTPService) Start() error

func (*SMTPService) Stop

func (ss *SMTPService) Stop() error

type Session added in v0.1.2

type Session struct {
	SMTPClient EmailSender
	DB         letterbox.Datastore
	DKIM       dkimChecker
	SPF        spfChecker
	Log        logger.Logger
	Banner     *banner.Builder
	MaxSize    int64
	Mailboxes  *letterbox.MailboxService
	Messages   *letterbox.MessageService
	Stats      *letterbox.MailboxStatsService

	RemoteAddr net.Addr
	Helo       string

	From    string
	To      string
	Mailbox *letterbox.Mailbox
}

func (*Session) Data added in v0.1.2

func (s *Session) Data(r io.Reader) error

func (*Session) Logout added in v0.1.2

func (s *Session) Logout() error

func (*Session) Mail added in v0.1.2

func (s *Session) Mail(from string, opts smtp.MailOptions) error

func (*Session) Rcpt added in v0.1.2

func (s *Session) Rcpt(to string) error

func (*Session) Reset added in v0.1.2

func (s *Session) Reset()

type TLSConfig added in v0.1.2

type TLSConfig struct {
	// The certificate string
	Cert string `json:"cert,omitempty"`

	// The (unencrypted) private key string
	Key string `json:"key,omitempty"`

	// The path to the file containing the certificate
	CertFile string `json:"cert_file,omitempty"`

	// The path to the file containing the (unencrypted) private key
	KeyFile string `json:"key_file,omitempty"`

	// The port to use for the TLS-only SMTPS server
	// This server is wrapped with TLS, and doesn't use the STARTTLS function
	// See RFC8314
	Port int `json:"port,omitempty"`
}

func (*TLSConfig) Validate added in v0.1.2

func (c *TLSConfig) Validate() error

Directories

Path Synopsis
Vendored code from https://github.com/ArkaGPL/parsemail This code addresses some fixes missing from github.com/DusanKasan/parsemail.
Vendored code from https://github.com/ArkaGPL/parsemail This code addresses some fixes missing from github.com/DusanKasan/parsemail.
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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