// Package main implements mail-admin, a read-only web view of the // docker-mailserver accounts on mail.produktor.io. package main import ( "bufio" "io" "strings" ) // Account is one mailbox from postfix-accounts.cf. type Account struct { Email string // full address, e.g. info@produktor.io Hash string // SHA512-CRYPT hash from the accounts file (never displayed) } // parseAccounts reads a docker-mailserver postfix-accounts.cf file: one // "email|hash" per line, '#' comments and blank lines skipped. Malformed // lines are skipped, not fatal: a broken line must not hide the other // accounts. func parseAccounts(r io.Reader) ([]Account, error) { sc := bufio.NewScanner(r) var out []Account for sc.Scan() { line := strings.TrimSpace(sc.Text()) if line == "" || strings.HasPrefix(line, "#") { continue } email, hash, ok := strings.Cut(line, "|") email = strings.TrimSpace(email) if !ok || email == "" { continue } out = append(out, Account{Email: email, Hash: strings.TrimSpace(hash)}) } return out, sc.Err() }