postfix

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package postfix runs Postfix command-line tools (postqueue, postconf, postsuper). Commands are executed directly, never through a shell.

Index

Constants

This section is empty.

Variables

View Source
var LogCandidates = []string{"/var/log/mail.log", "/var/log/maillog", "/var/log/mail/mail.log", "/var/log/postfix.log", "/var/log/mail/maillog"}

LogCandidates are tried in order when no log source is given.

Functions

func ParseConfig

func ParseConfig(s string) map[string]string

ParseConfig parses `postconf` output ("name = value" lines).

func ValidQueueID

func ValidQueueID(id string) bool

ValidQueueID reports whether id looks like a Postfix queue ID (short or long form).

Types

type LogSource

type LogSource struct {
	Files []string // explicit files (.gz ok, "-" = stdin)
	Cmd   string   // explicit command, split on spaces, e.g. "journalctl -u postfix -o short-iso"
}

LogSource describes where Postfix log lines come from.

type Runner

type Runner struct {
	Wrap    []string
	Timeout time.Duration
}

Runner executes Postfix commands, optionally behind a wrapper such as "docker exec -i mailserver" or "ssh mail sudo".

func (Runner) Config

func (r Runner) Config(ctx context.Context) (map[string]string, error)

Config returns non-default main.cf settings (`postconf -n`) as a map. Values of parameters that look like secrets are redacted.

func (Runner) Flush

func (r Runner) Flush(ctx context.Context, ids []string, site string, all bool) ([]string, error)

Flush asks Postfix to retry delivery: of specific queue IDs (postqueue -i), of everything for one destination (postqueue -s), or of the whole queue (postqueue -f).

func (Runner) OpenLogs

func (r Runner) OpenLogs(ctx context.Context, src LogSource, mailLogFile string, since time.Time) ([]io.ReadCloser, string, error)

OpenLogs returns readers for the configured log source, a description of what was opened, or an error when nothing readable was found. mailLogFile is Postfix's maillog_file setting (may be empty).

func (Runner) Params

func (r Runner) Params(ctx context.Context, names ...string) (map[string]string, error)

Params returns expanded values (`postconf -x`) of the given parameters.

func (Runner) QueueJSON

func (r Runner) QueueJSON(ctx context.Context) ([]byte, error)

QueueJSON returns the output of `postqueue -j`.

func (Runner) Run

func (r Runner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

Run executes name with args and returns stdout.

func (Runner) Super

func (r Runner) Super(ctx context.Context, op string, ids []string) ([]string, error)

Super runs `postsuper -<op> ID` for each ID. op is one of r (requeue), d (delete), h (hold), H (release from hold).

Jump to

Keyboard shortcuts

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