Billionmail/BillionMail · error

failed to read postfix master config: %v

Error message

failed to read postfix master config: %v

What it means

SetPostfixMasterSSL reads Postfix's master.cf (consts.POSTFIX_MASTER_CONF) via public.ReadFile before uncommenting TLS options. This error wraps the read failure, so the message text is the underlying OS error (e.g. 'no such file or directory' or 'permission denied').

Source

Thrown at core/internal/service/mail_service/certificate.go:164

	// Update Postfix Master configuration
	if err := c.SetPostfixMasterSSL(); err != nil {
		return err
	}

	// Restart Postfix service
	if err := c.restartPostfix(); err != nil {
		return err
	}

	return nil
}

// SetPostfixMasterSSL enables SSL for Postfix Master
func (c *Certificate) SetPostfixMasterSSL() error {
	// Read Postfix Master configuration
	content, err := public.ReadFile(consts.POSTFIX_MASTER_CONF)
	if err != nil {
		return fmt.Errorf("failed to read postfix master config: %v", err)
	}

	content, err = gregex.ReplaceString(`\n*#\s*-o\s+smtpd_tls_auth_only=yes`, "\n  -o smtpd_tls_auth_only=yes", content)

	if err != nil {
		return fmt.Errorf("failed to update postfix master config: %v", err)
	}

	content, err = gregex.ReplaceString(`\n*#\s*-o\s+smtpd_tls_wrappermode=yes`, "\\n  -o smtpd_tls_wrappermode=yes", content)

	if err != nil {
		return fmt.Errorf("failed to update postfix master config: %v", err)
	}

	// Update Postfix Master configuration
	if err := os.WriteFile(c.PostfixMasterConf, []byte(content), 0755); err != nil {
		return fmt.Errorf("failed to write postfix master config: %v", err)
	}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Verify POSTFIX_MASTER_CONF points to the actual master.cf location (postconf -h config_directory)
  2. Install postfix or mount the postfix config into the container
  3. Grant read permission (or run as root) for the service reading master.cf
  4. Log the wrapped underlying error to confirm which path failed
Defensive patterns

Strategy: validation

Validate before calling

masterCf := consts.POSTFIX_MASTER_CONF
if _, err := os.Stat(masterCf); err != nil {
    return fmt.Errorf("postfix master.cf not available at %s: %w", masterCf, err)
}

Try / catch

if err := certService.SetPostfixMasterSSL(); err != nil {
    if strings.Contains(err.Error(), "failed to read postfix master config") {
        log.Errorf("master.cf unreadable: %s — is postfix installed and path correct?", err)
        return ErrPostfixNotConfigured
    }
    return err
}

Prevention

When it happens

Trigger: Calling SetPostfixSSL or SetPostfixVMailCert (which call SetPostfixMasterSSL) on a host where the master.cf path is wrong or unreadable.

Common situations: Postfix not installed or running inside a different container than the app; nonstandard postfix config directory; app container lacking root/permission to read /etc/postfix/master.cf.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/e906f3117a69cef9. Report an issue: GitHub.