simplelogin

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package simplelogin is a client of the SimpleLogin API (simplelogin.io and self-hosted instances), for the endpoints Godwit uses: the user's mailboxes and aliases, creating and toggling aliases, and the contacts whose reverse aliases mail from an alias is sent to.

The API is documented at https://github.com/simple-login/app/blob/master/docs/api.md. Every request carries the user's API key in the Authentication header.

Index

Constants

View Source
const DefaultBaseURL = "https://app.simplelogin.io"

DefaultBaseURL is SimpleLogin's own service.

Variables

View Source
var ErrUnauthorized = errors.New("simplelogin: the API key was refused")

ErrUnauthorized is the API's 401: the key is wrong, revoked or missing.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Action    string `json:"action"`
	Timestamp int64  `json:"timestamp"`
	Contact   struct {
		Email        string `json:"email"`
		Name         string `json:"name"`
		ReverseAlias string `json:"reverse_alias"`
	} `json:"contact"`
}

Activity is an alias's latest forward, reply, block or bounce.

type Alias

type Alias struct {
	ID             int64          `json:"id"`
	Email          string         `json:"email"`
	Name           string         `json:"name"`
	Note           string         `json:"note"`
	Enabled        bool           `json:"enabled"`
	Pinned         bool           `json:"pinned"`
	Created        int64          `json:"creation_timestamp"`
	Forwards       int            `json:"nb_forward"`
	Replies        int            `json:"nb_reply"`
	Blocks         int            `json:"nb_block"`
	Mailboxes      []AliasMailbox `json:"mailboxes"`
	LatestActivity *Activity      `json:"latest_activity"`
}

Alias is one of the user's aliases.

type AliasMailbox

type AliasMailbox struct {
	ID    int64  `json:"id"`
	Email string `json:"email"`
}

AliasMailbox is one of the mailboxes an alias forwards to.

type AliasPatch

type AliasPatch struct {
	Name       *string `json:"name,omitempty"`
	Note       *string `json:"note,omitempty"`
	MailboxIDs []int64 `json:"mailbox_ids,omitempty"`
}

AliasPatch changes the alias's fields that are not nil.

type Client

type Client struct {
	BaseURL string       // scheme and host, with no trailing slash: DefaultBaseURL or a self-hosted one
	Key     string       // the user's API key
	HTTP    *http.Client // nil: http.DefaultClient; redirects are refused either way
}

Client calls one SimpleLogin instance as one user.

func (*Client) Alias

func (c *Client) Alias(ctx context.Context, id int64) (Alias, error)

Alias reads one alias.

func (*Client) Aliases

func (c *Client) Aliases(ctx context.Context) ([]Alias, error)

Aliases lists every alias of the user, reading page after page until one comes back empty.

func (*Client) CreateContact

func (c *Client) CreateContact(ctx context.Context, aliasID int64, contact string) (Contact, error)

CreateContact adds contact ("Name <address>" or a bare address) to the alias, or returns the existing one (Existed).

func (*Client) CreateCustom

func (c *Client) CreateCustom(ctx context.Context, a CustomAlias, hostname string) (Alias, error)

CreateCustom creates a custom alias, used on hostname ("" for none).

func (*Client) CreateRandom

func (c *Client) CreateRandom(ctx context.Context, note, mode, hostname string) (Alias, error)

CreateRandom creates a random alias forwarding to the default mailbox. mode is "word", "uuid" or "" for the user's setting.

func (*Client) Mailboxes

func (c *Client) Mailboxes(ctx context.Context) ([]Mailbox, error)

Mailboxes lists the user's mailboxes, unverified ones included.

func (*Client) Options

func (c *Client) Options(ctx context.Context, hostname string) (Options, error)

Options is what a new alias for hostname ("" for none) can be.

func (*Client) Toggle

func (c *Client) Toggle(ctx context.Context, id int64) (bool, error)

Toggle switches the alias on or off and returns whether it is now on.

func (*Client) Update

func (c *Client) Update(ctx context.Context, id int64, p AliasPatch) error

Update changes the alias's fields p sets.

type Contact

type Contact struct {
	ID                  int64  `json:"id"`
	Contact             string `json:"contact"`
	ReverseAlias        string `json:"reverse_alias"`         // a header address: a display name and ReverseAliasAddress
	ReverseAliasAddress string `json:"reverse_alias_address"` // the bare address
	Existed             bool   `json:"existed"`
}

Contact is a correspondent of an alias. Mail from the alias to Contact is sent to ReverseAliasAddress from one of the alias's mailboxes; SimpleLogin rewrites its From to the alias.

type CustomAlias

type CustomAlias struct {
	Prefix       string  `json:"alias_prefix"`
	SignedSuffix string  `json:"signed_suffix"`
	MailboxIDs   []int64 `json:"mailbox_ids"`
	Note         string  `json:"note,omitempty"`
	Name         string  `json:"name,omitempty"`
}

CustomAlias is a custom alias to create: Prefix followed by the suffix SignedSuffix names, forwarding to MailboxIDs (at least one).

type Error

type Error struct {
	Status  int
	Message string
}

Error is a refusal the API explained, such as an alias quota reached or a reverse alias that needs a premium plan: the API documents Message as fit to show the user as it is.

func (*Error) Error

func (e *Error) Error() string

type Mailbox

type Mailbox struct {
	ID       int64  `json:"id"`
	Email    string `json:"email"`
	Default  bool   `json:"default"`
	Verified bool   `json:"verified"`
	Aliases  int    `json:"nb_alias"`
}

Mailbox is a mailbox of the user's: a real address aliases forward to.

type Options

type Options struct {
	CanCreate        bool     `json:"can_create"`
	PrefixSuggestion string   `json:"prefix_suggestion"`
	Suffixes         []Suffix `json:"suffixes"`
}

Options is what a new alias can be: whether the user may create one, the suffixes a custom one can end with, and a prefix suggested for hostname.

type Suffix

type Suffix struct {
	Suffix       string `json:"suffix"`
	SignedSuffix string `json:"signed_suffix"`
	Custom       bool   `json:"is_custom"`
	Premium      bool   `json:"is_premium"`
}

Suffix is a suffix a custom alias can end with; SignedSuffix is what a creation names, so the server knows it offered it.

Directories

Path Synopsis
Package simplelogintest is a fake SimpleLogin API for tests: a user with mailboxes, aliases and contacts, served over HTTP on loopback.
Package simplelogintest is a fake SimpleLogin API for tests: a user with mailboxes, aliases and contacts, served over HTTP on loopback.

Jump to

Keyboard shortcuts

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