emailctl

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 9 Imported by: 0

README

emailctl

emailctl is a command line interface (CLI) for the Postfix Rest Server V1 API.

emailctl currently implements all Postfix Rest Server APIs (domains, accounts, aliases, automatic sender and recipient BCC).

emailctl is a command line interface (CLI) to the Postfix Rest Server

Usage:
  emailctl [command]

Available Commands:
  account       Account commands
  alias         Alias commands
  auth          Authentication commands
  domain        Domain commands
  help          Help about any command
  recipient-bcc recipient-bcc commands
  sender-bcc    sender-bcc commands
  version       Prints the version number of emailctl

Flags:
      --config string   config file (default is $HOME/.emailctl.yaml)
  -h, --help            help for emailctl

Use "emailctl [command] --help" for more information about a command.

Installation

Install from source

If you have a Go environment configured, you can install the latest development version of emailctl directly from my GitHub account from the command line like so:

go get github.com/lyubenblagoev/emailctl/...

which will install the executable in your GOPATH, or you can build it with the following command and move the executable somewhere under PATH:

go build -o some-path/emailctl ./cmd/emailctl

Configuration

By default emailctl will load a configuration file from $HOME/.emailctl.yaml.

Configuration options

Example:

https: false
host: localhost
port: 8080

The above values are the defaults. You can omit options that don't change the default values.

Examples

Below are a few usage examples:

Authentication
  • Log in
emailctl auth login admin@example.com
  • Log out
emailctl auth logout
Domain API
  • List all domains on your server:
emailctl domain list
  • Show information for specific domain:
emailctl domain show example.com
  • Add a new domain:
emailctl domain add example.com
  • Delete a domain:
emailctl domain delete example.com
  • Disable a domain on your server:
emailctl domain disable example.com
  • Rename a domain
emailctl domain rename example.com example.net
Account API
  • List accounts for domain:
emailctl account list example.com
  • Show information for account in specific domain:
emailctl account show example.com user1
  • Delete account:
emailctl account delete example.com user1
  • Disable account:
emailctl account disable example.com user1
  • Change password for account:
emailctl account password example.com user1
Password: 
Confirm password: 

More information

To learn more about the features and commands available run

emailctl help [command [sub-command]...]

or

emailctl [command [sub-command]...] --help

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAndConfirmPassword

func ReadAndConfirmPassword() (string, error)

ReadAndConfirmPassword reads a password and confirmation from the terminal. Retries three times if the passwords do not match.

func ReadPassword

func ReadPassword(prompt string) (string, error)

ReadPassword reads a password from the terminal

func ValidateEmail

func ValidateEmail(email string) error

ValidateEmail validates the given email address and returns an error if the email address is invalid.

func ValidateEmailFromParts

func ValidateEmailFromParts(name, domain string) error

ValidateEmailFromParts validates the email address using the given username and domain and returns an error if the email address is invalid.

Types

type Account

type Account struct {
	*goprsc.Account
}

Account is a wrapper for goprsc.Account.

type AccountService

type AccountService service

AccountService handles communication with the account API on the Postfix REST Server.

func (*AccountService) ChangePassword

func (s *AccountService) ChangePassword(domain, username, password string) error

ChangePassword changes the password for the specified account.

func (*AccountService) Create

func (s *AccountService) Create(domain, username, password string) error

Create creates a new account in the specified domain with the given username and password.

func (*AccountService) Delete

func (s *AccountService) Delete(domain, username string) error

Delete deletes the specified account.

func (*AccountService) Disable

func (s *AccountService) Disable(domain, username string) error

Disable disables the specified account.

func (*AccountService) Enable

func (s *AccountService) Enable(domain, username string) error

Enable enables the specified account.

func (*AccountService) Get

func (s *AccountService) Get(domain string, username string) (*Account, error)

Get retrieves the account for domain 'domain' with name 'username'.

func (*AccountService) List

func (s *AccountService) List(domain string) ([]Account, error)

List retrieves all accounts for the specified domain.

func (*AccountService) Rename

func (s *AccountService) Rename(domain, old, new string) error

Rename renames the specified account username from 'old'@domain to 'new'@domain.

type Alias

type Alias struct {
	*goprsc.Alias
}

Alias is a wrapper for goprsc.Alias.

type AliasService

type AliasService service

AliasService handles communication with the alias API of the Postfix REST Server.

func (*AliasService) Create

func (s *AliasService) Create(domain, alias, email string) error

Create assignes email to the specified alias.

func (*AliasService) Delete

func (s *AliasService) Delete(domain, alias, email string) error

Delete deletes the specified alias.

func (*AliasService) DeleteAll

func (s *AliasService) DeleteAll(domain, alias string) error

DeleteAll deletes all recipients for a specific alias.

func (*AliasService) Disable

func (s *AliasService) Disable(domain, alias, email string) error

Disable disables the specified alias.

func (*AliasService) Enable

func (s *AliasService) Enable(domain, alias, email string) error

Enable enables the specified alias.

func (*AliasService) Get

func (s *AliasService) Get(domain, alias string) ([]Alias, error)

Get retrieves all recipients for the specified alias.

func (*AliasService) GetForEmail

func (s *AliasService) GetForEmail(domain, alias, email string) (*Alias, error)

GetForEmail retreives a specific alias.

func (*AliasService) List

func (s *AliasService) List(domain string) ([]Alias, error)

List retrieves all aliases for accounts in the specified domain.

func (*AliasService) Rename

func (s *AliasService) Rename(domain, alias, email, newName string) error

Rename changes the username part of the specified alias forwarding to the specified email address.

func (*AliasService) RenameAll

func (s *AliasService) RenameAll(domain, alias, newName string) error

RenameAll renames the username part of the specified aliases (for all recipients attached to the alias).

type AuthResponse

type AuthResponse struct {
	*goprsc.AuthResponse
}

AuthResponse is a wrapper for goprsc.AuthResponse

type AuthService

type AuthService service

AuthService handles communication with the authentication API of the Postfix REST Server.

func (*AuthService) Login

func (s *AuthService) Login(login, password string) (*AuthResponse, error)

Login authenticates the user credential and returnes the tokens provided by the Postfix REST Server.

func (*AuthService) Logout

func (s *AuthService) Logout(login, refreshToken string) error

Logout logs out the user, if the provided login and refreshToken are valid.

type Bcc

type Bcc struct {
	*goprsc.Bcc
}

Bcc is a wrapper for goprsc.Bcc

type BccService

type BccService interface {
	Get(domain, username string) (*Bcc, error)
	Create(domain, username, email string) error
	Delete(domain, username string) error
	Enable(domain, username string) error
	Disable(domain, username string) error
	ChangeRecipient(domain, username, email string) error
}

BccService handles communication with the BCC API.

type Client

type Client struct {
	Auth       *AuthService
	Domains    *DomainService
	Accounts   *AccountService
	Aliases    *AliasService
	InputBccs  *InputBccService
	OutputBccs *OutputBccService
	// contains filtered or unexported fields
}

Client is the Postfix REST server client.

func NewClient

func NewClient() (*Client, error)

NewClient creates an instance of Client.

func (*Client) GetAuthToken

func (c *Client) GetAuthToken() string

GetAuthToken returns the authentication token associated with the client

func (*Client) GetLogin

func (c *Client) GetLogin() string

GetLogin returns the user login associated with the client

func (*Client) GetRefreshToken

func (c *Client) GetRefreshToken() string

GetRefreshToken returns the refresh token associated with the client

type Domain

type Domain struct {
	*goprsc.Domain
}

Domain is a wrapper for goprsc.Domain

type DomainService

type DomainService service

DomainService handles communication with the domain API of the Postfix REST Server.

func (*DomainService) Create

func (s *DomainService) Create(name string) error

Create creates a new domain with the specified domain name.

func (*DomainService) Delete

func (s *DomainService) Delete(name string) error

Delete deletes the domain with the specified name.

func (*DomainService) Disable

func (s *DomainService) Disable(name string) error

Disable disables the domain specified by 'name'.

func (*DomainService) Enable

func (s *DomainService) Enable(name string) error

Enable enables the domain specified by 'name'.

func (*DomainService) Get

func (s *DomainService) Get(name string) (*Domain, error)

Get retrieves a domain with the specified domain name

func (*DomainService) List

func (s *DomainService) List() ([]Domain, error)

List retrieves all domains.

func (*DomainService) Rename

func (s *DomainService) Rename(old, new string) error

Rename renames domain with domain name 'old' to 'new'.

type InputBccService

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

InputBccService handles communication with the recipient BCC API.

func NewInputBccService

func NewInputBccService(client *goprsc.Client) *InputBccService

NewInputBccService builds a new InputBccServer instance for interacting with the recipient BCC API.

func (InputBccService) ChangeRecipient

func (s InputBccService) ChangeRecipient(domain, username, email string) error

func (InputBccService) Create

func (s InputBccService) Create(domain, username, email string) error

func (InputBccService) Delete

func (s InputBccService) Delete(domain, username string) error

func (InputBccService) Disable

func (s InputBccService) Disable(domain, username string) error

func (InputBccService) Enable

func (s InputBccService) Enable(domain, username string) error

func (InputBccService) Get

func (s InputBccService) Get(domain, username string) (*Bcc, error)

type OutputBccService

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

OutputBccService handles communication with the sender BCC API.

func NewOutputBccService

func NewOutputBccService(client *goprsc.Client) *OutputBccService

NewOutputBccService builds a new OutputBccService instance for interacting with the sender BCC API.

func (OutputBccService) ChangeRecipient

func (s OutputBccService) ChangeRecipient(domain, username, email string) error

func (OutputBccService) Create

func (s OutputBccService) Create(domain, username, email string) error

func (OutputBccService) Delete

func (s OutputBccService) Delete(domain, username string) error

func (OutputBccService) Disable

func (s OutputBccService) Disable(domain, username string) error

func (OutputBccService) Enable

func (s OutputBccService) Enable(domain, username string) error

func (OutputBccService) Get

func (s OutputBccService) Get(domain, username string) (*Bcc, error)

type Version

type Version struct {
	// Major is the major version number
	Major int
	// Minor is the minor version number
	Minor int
	// Patch is the patch version number
	Patch int
}

Version holds application version information.

func (Version) FullVersion

func (v Version) FullVersion() string

FullVersion returns the complete version string for emailctl.

func (Version) String

func (v Version) String() string

String returns a version string in format MAJOR.MINOR.PATCH

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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