mailu

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mailu provisions member mailboxes on the self-hosted Mailu stack via its admin REST API. Every verified AgentBBS member gets a real mailbox at <name>@<domain> (e.g. alice@bbs.profullstack.com); the agentbbs gateway then opens it over IMAP with the Dovecot master user, so members never manage an IMAP/SMTP password. Mailbox creation is the one thing that must happen up front, which is what EnsureUser does (idempotently).

The Mailu admin API listens on the loopback HTTP front (default http://127.0.0.1:8080) and authenticates with the token set as API_TOKEN in mailu.env. When no token is configured Configured() reports false and callers skip provisioning (the address is still shown).

Config (env):

AGENTBBS_MAIL_ADMIN_URL   Mailu admin base URL (default http://127.0.0.1:8080)
AGENTBBS_MAIL_API_TOKEN   Mailu API token (from mailu.env API_TOKEN)
AGENTBBS_MAIL_QUOTA_BYTES  per-mailbox quota in bytes (default 1 GiB)

Index

Constants

View Source
const DefaultQuotaBytes = 1 << 30

DefaultQuotaBytes is the per-mailbox storage quota when unset (1 GiB).

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the Mailu admin REST API.

func New

func New(cfg Config) *Client

New builds a client. NewFromEnv is the usual entry point.

func NewFromEnv

func NewFromEnv() *Client

NewFromEnv builds a client from the environment.

func (*Client) Configured

func (c *Client) Configured() bool

Configured reports whether mailboxes can actually be provisioned.

func (*Client) EnsureUser

func (c *Client) EnsureUser(ctx context.Context, localPart, domain string) error

EnsureUser creates email@... if it doesn't exist. It is idempotent: an existing mailbox (or an "already exists" create response) is success. The generated password is unused by members — the gateway master user opens every mailbox — but Mailu requires one at creation time.

func (*Client) SetPassword

func (c *Client) SetPassword(ctx context.Context, localPart, domain, password string) error

SetPassword sets the mailbox password (so the member can log into webmail). The gateway opens mailboxes via the Dovecot master user and never needs this, but webmail (Roundcube) requires the member to have a known password.

func (*Client) UserExists

func (c *Client) UserExists(ctx context.Context, email string) (bool, error)

UserExists reports whether email already has a mailbox.

type Config

type Config struct {
	BaseURL    string
	Token      string
	QuotaBytes int64
	HTTP       *http.Client
}

Config holds the Mailu admin-API endpoint and credentials.

func ConfigFromEnv

func ConfigFromEnv() Config

ConfigFromEnv reads the Mailu admin settings from the environment.

Jump to

Keyboard shortcuts

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