Documentation
¶
Overview ¶
Package mailhost manages hosted email (domains and mailboxes) on a Stalwart mail server through its JMAP management API (Stalwart 0.16+: urn:stalwart:jmap, x:Domain / x:Account).
Index ¶
- Variables
- func ParseZoneFile(zone string) []dns.RRSet
- func ValidLocal(l string) bool
- type MailboxUpdate
- type Server
- type Settings
- type Stalwart
- func (s *Stalwart) CreateDomain(ctx context.Context, name string) (string, error)
- func (s *Stalwart) CreateMailbox(ctx context.Context, domainID, local, password string, quotaMB int, ...) (string, error)
- func (s *Stalwart) DeleteDomain(ctx context.Context, id string) error
- func (s *Stalwart) DeleteMailbox(ctx context.Context, id string) error
- func (s *Stalwart) DomainRecords(ctx context.Context, id string) ([]dns.RRSet, error)
- func (s *Stalwart) UpdateMailbox(ctx context.Context, id string, u MailboxUpdate) error
- func (s *Stalwart) Usage(ctx context.Context, ids []string) (map[string]int64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrExists = errors.New("already exists on the mail server")
ErrExists is returned when the mail server already has the domain or address.
Functions ¶
func ParseZoneFile ¶
ParseZoneFile reads the BIND-style records Stalwart suggests (one per line, TXT values possibly split over parenthesised lines) into canonical record sets.
func ValidLocal ¶
ValidLocal checks the part of an address before the @.
Types ¶
type MailboxUpdate ¶
type MailboxUpdate struct {
Password *string
QuotaMB *int
Aliases *[]string // local parts on the mailbox's domain
DomainID string // needed with Aliases
}
MailboxUpdate changes the fields that are not nil.
type Server ¶
type Server interface {
CreateDomain(ctx context.Context, name string) (id string, err error)
// DeleteDomain removes the domain with its DKIM keys (mailboxes must be deleted first).
DeleteDomain(ctx context.Context, id string) error
// DomainRecords are the DNS records the domain needs (MX, SPF, DKIM, DMARC, SRV, ...).
DomainRecords(ctx context.Context, id string) ([]dns.RRSet, error)
CreateMailbox(ctx context.Context, domainID, local, password string, quotaMB int, aliases []string) (id string, err error)
UpdateMailbox(ctx context.Context, id string, u MailboxUpdate) error
DeleteMailbox(ctx context.Context, id string) error
// Usage returns the used storage (bytes) per mailbox ID.
Usage(ctx context.Context, ids []string) (map[string]int64, error)
}
Server is a mail server the panel manages.
type Settings ¶
type Settings struct {
URL string `json:"url"` // Stalwart HTTP endpoint; empty = email hosting off
Username string `json:"username"`
Password string `json:"password"`
IMAPHost string `json:"imap_host"` // shown to customers, e.g. mail.example.com
SMTPHost string `json:"smtp_host"`
WebmailURL string `json:"webmail_url"`
MaxMailboxes int `json:"max_mailboxes"` // default per new domain
MaxQuotaMB int `json:"max_quota_mb"` // default per mailbox
}
Settings configure hosted email (stored as JSON under the "mail_hosting" key; "mail" is the panel's own SMTP).
type Stalwart ¶
type Stalwart struct {
URL string // e.g. https://mail.example.com (the HTTP listener with /jmap)
Username string // an administrator, e.g. admin@example.com
Password string
Client *http.Client
}
Stalwart is the JMAP management client.