Documentation
¶
Overview ¶
Package postfix runs Postfix command-line tools (postqueue, postconf, postsuper). Commands are executed directly, never through a shell.
Index ¶
- Variables
- func ParseConfig(s string) map[string]string
- func ValidQueueID(id string) bool
- type LogSource
- type Runner
- func (r Runner) Config(ctx context.Context) (map[string]string, error)
- func (r Runner) Flush(ctx context.Context, ids []string, site string, all bool) ([]string, error)
- func (r Runner) OpenLogs(ctx context.Context, src LogSource, mailLogFile string, since time.Time) ([]io.ReadCloser, string, error)
- func (r Runner) Params(ctx context.Context, names ...string) (map[string]string, error)
- func (r Runner) QueueJSON(ctx context.Context) ([]byte, error)
- func (r Runner) Run(ctx context.Context, name string, args ...string) ([]byte, error)
- func (r Runner) Super(ctx context.Context, op string, ids []string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
ParseConfig parses `postconf` output ("name = value" lines).
func ValidQueueID ¶
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 ¶
Runner executes Postfix commands, optionally behind a wrapper such as "docker exec -i mailserver" or "ssh mail sudo".
func (Runner) Config ¶
Config returns non-default main.cf settings (`postconf -n`) as a map. Values of parameters that look like secrets are redacted.
func (Runner) Flush ¶
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).