gospam

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 15 Imported by: 0

README

GoSpam

Simple selfhosted throw-away email

Configuration

GoSpam supports various configuration options. All options with their respective defaults are listed below. The configuration file is a yaml file and can be located in the current directory (gospam.conf) in etc (/etc/gospam/gospam.conf) or in the users home directory ($HOME/.gospam/gospam.conf).

SMTPListenAddress: ":25"
HTTPListenAddress: ":80"
Domain: "localhost"
AcceptedDomains:
  - "spam4.jonaskoeritz.de"
  - "localhost"
AcceptSubdomains: false
MaxStoredMessages: 100000
RetentionHours: 4
CleanupPeriod: 5
MaximumMessageSize: 5242880
SMTPTimeout: 60
MaxRecipients: 10
RandomAliasPlaceholder: false

AcceptedDomains can be omitted to accept any recipient domain, this will make the server look like an open relay.

To add persistence to the service you can optionally supply connection details for a Redis server:

RedisBackend:
  Address: "127.0.0.1:6379"
  Password: ""
  DB: 0

The MaxStoredMessages does not apply to the redis backend. Additionally searching for aliases using * and ? placeholders is available only when using the redis backend.

Setup

Just run the gospam binary.

You have to create DNS records to configure the machine running GoSpam as the mail server for any domain or subdomain.

The web interface can be configured to listen on a specific interface only (e. g. 127.0.0.1:80 to listen on localhost) this makes it possible to make the SMTP listener publicly accessible and keep the web interface private.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	smtp.Backend
	SaveEmail(*EMail)
	IsAcceptedDomain(email string) bool
	GetProcessedEmails() int
	GetEmailsByAlias(alias string) []*EMail
	GetEmailById(id int) *EMail
	Cleanup(deadline time.Time)
}

func NewRedisBackend

func NewRedisBackend(addr string, password string, db int, acceptedDomains []string, acceptSubdomains bool, retentionHours int) Backend

type EMail

type EMail struct {
	ID      int
	Time    time.Time
	From    string
	To      []string
	Body    []byte
	Header  mail.Header
	Subject string
	Data    []byte
}

type InMemoryBackend

type InMemoryBackend struct {
	MaxStoredMessage int

	AcceptedDomains  []string
	AcceptSubdomains bool
	// contains filtered or unexported fields
}

func (*InMemoryBackend) AnonymousLogin

func (backend *InMemoryBackend) AnonymousLogin(c *smtp.ConnectionState) (smtp.Session, error)

func (*InMemoryBackend) Cleanup

func (b *InMemoryBackend) Cleanup(deadline time.Time)

func (*InMemoryBackend) GetEmailById

func (b *InMemoryBackend) GetEmailById(id int) *EMail

func (*InMemoryBackend) GetEmailsByAlias

func (b *InMemoryBackend) GetEmailsByAlias(alias string) []*EMail

func (*InMemoryBackend) GetProcessedEmails

func (b *InMemoryBackend) GetProcessedEmails() int

func (*InMemoryBackend) IsAcceptedDomain

func (b *InMemoryBackend) IsAcceptedDomain(email string) bool

func (*InMemoryBackend) Login

func (backend *InMemoryBackend) Login(_ *smtp.ConnectionState, username, password string) (smtp.Session, error)

func (*InMemoryBackend) NewSession

func (backend *InMemoryBackend) NewSession(c smtp.ConnectionState, _ string) (smtp.Session, error)

func (*InMemoryBackend) SaveEmail

func (b *InMemoryBackend) SaveEmail(email *EMail)

type RedisBackend

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

func (*RedisBackend) AnonymousLogin

func (backend *RedisBackend) AnonymousLogin(c *smtp.ConnectionState) (smtp.Session, error)

func (*RedisBackend) Cleanup

func (b *RedisBackend) Cleanup(deadline time.Time)

func (*RedisBackend) GetEmailById

func (b *RedisBackend) GetEmailById(id int) *EMail

func (*RedisBackend) GetEmailsByAlias

func (b *RedisBackend) GetEmailsByAlias(alias string) []*EMail

func (*RedisBackend) GetProcessedEmails

func (b *RedisBackend) GetProcessedEmails() int

func (*RedisBackend) IsAcceptedDomain

func (b *RedisBackend) IsAcceptedDomain(email string) bool

func (*RedisBackend) Login

func (backend *RedisBackend) Login(_ *smtp.ConnectionState, username, password string) (smtp.Session, error)

func (*RedisBackend) NewSession

func (backend *RedisBackend) NewSession(c smtp.ConnectionState, _ string) (smtp.Session, error)

func (*RedisBackend) SaveEmail

func (b *RedisBackend) SaveEmail(email *EMail)

type Session

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

func (*Session) AuthPlain

func (s *Session) AuthPlain(username, password string) error

func (*Session) Data

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

func (*Session) Logout

func (s *Session) Logout() error

func (*Session) Mail

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

func (*Session) Rcpt

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

func (*Session) Reset

func (s *Session) Reset()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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