mailfull

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2018 License: MIT Imports: 15 Imported by: 0

README

mailfull-go

A management tool for virtual domain email for Postfix and Dovecot written in Go.

GoDoc

Features

  • You can use both virtual users and system users.
  • Mailfull does not involve in delivery processes of the MTA, is only to generate configuration databases.
  • You do not need to restart Postfix/Dovecot to apply configuration databases.
  • The received email can be passed to the programs.

Installation

Binary

You can download archive file from releases page .
Download and unpack the archive file, and put the binary file to somewhere you want.

go get

Installed in $GOPATH/bin

$ go get github.com/directorz/mailfull-go/cmd/mailfull

Quick Start

Create a new user for Mailfull.

# useradd -r -s /bin/bash mailfull
# su - mailfull

Initialize a directory as a Mailfull repository.

$ mkdir /path/to/repo && cd /path/to/repo
$ mailfull init
$ mailfull commit

Generate configurations for Postfix and Dovecot. (Edit as needed.)

$ mailfull genconfig postfix > /etc/postfix/main.cf
$ mailfull genconfig dovecot > /etc/dovecot/dovecot.conf

Start Postfix and Dovecot.

# systemctl start postfix.service
# systemctl start dovecot.service

Add a new domain and user.

# cd /path/to/repo

# mailfull domainadd example.com
# mailfull useradd hoge@example.com
# mailfull userpasswd hoge@example.com

Enjoy!

More info

See documentation

Documentation

Overview

Package mailfull contains operations for a mailfull repository.

Index

Constants

View Source
const (
	DirNameConfig  = ".mailfull"
	FileNameConfig = "config"

	FileNameDomainDisable = ".vdomaindisable"
	FileNameAliasDomains  = ".valiasdomains"
	FileNameUsersPassword = ".vpasswd"
	FileNameUserForwards  = ".forward"
	FileNameAliasUsers    = ".valiases"
	FileNameCatchAllUser  = ".vcatchall"

	FileNameDbDomains      = "domains"
	FileNameDbDestinations = "destinations"
	FileNameDbMaildirs     = "maildirs"
	FileNameDbLocaltable   = "localtable"
	FileNameDbForwards     = "forwards"
	FileNameDbPasswords    = "vpasswd"
)

Filenames that are contained in the Repository.

View Source
const NeverMatchHashedPassword = "{SSHA}!!"

NeverMatchHashedPassword is hash string that is never match with any password.

View Source
const Version = "v1.0.3"

Version is a version number.

Variables

View Source
var (
	ErrInvalidRepository = errors.New("invalid repository")
	ErrNotRepository     = errors.New("not a Mailfull repository (or any of the parent directories)")
	ErrRepositoryExist   = errors.New("a Mailfull repository exists")
)

Errors for the Repository.

View Source
var (
	ErrDomainNotExist            = errors.New("Domain: not exist")
	ErrDomainAlreadyExist        = errors.New("Domain: already exist")
	ErrDomainIsAliasDomainTarget = errors.New("Domain: is set as alias")

	ErrAliasDomainNotExist     = errors.New("AliasDomain: not exist")
	ErrAliasDomainAlreadyExist = errors.New("AliasDomain: already exist")

	ErrUserNotExist       = errors.New("User: not exist")
	ErrUserAlreadyExist   = errors.New("User: already exist")
	ErrUserIsCatchAllUser = errors.New("User: is set as catchall")

	ErrAliasUserNotExist     = errors.New("AliasUser: not exist")
	ErrAliasUserAlreadyExist = errors.New("AliasUser: already exist")

	ErrInvalidFormatDomainDisabled = errors.New("Domain: disabled file invalid format")
	ErrInvalidFormatUsersPassword  = errors.New("User: password file invalid format")
	ErrInvalidFormatAliasDomain    = errors.New("AliasDomain: file invalid format")
	ErrInvalidFormatAliasUsers     = errors.New("AliasUsers: file invalid format")
)

Errors for the operation of the Repository.

View Source
var (
	ErrInvalidDomainName        = errors.New("Domain: name incorrect format")
	ErrInvalidAliasDomainName   = errors.New("AliasDomain: name incorrect format")
	ErrInvalidAliasDomainTarget = errors.New("AliasDomain: target incorrect format")
	ErrInvalidUserName          = errors.New("User: name incorrect format")
	ErrInvalidAliasUserName     = errors.New("AliasUser: name incorrect format")
	ErrInvalidAliasUserTarget   = errors.New("AliasUser: target incorrect format")
	ErrInvalidCatchAllUserName  = errors.New("CatchAllUser: name incorrect format")
)

Errors for incorrect format.

View Source
var (
	ErrNotEnoughAliasUserTargets = errors.New("AliasUser: targets not enough")
)

Errors for parameter.

Functions

func InitRepository

func InitRepository(rootPath string) error

InitRepository initializes the input directory as a Repository.

Types

type AliasDomain

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

AliasDomain represents a AliasDomain.

func NewAliasDomain

func NewAliasDomain(name, target string) (*AliasDomain, error)

NewAliasDomain creates a new AliasDomain instance.

func (*AliasDomain) Name

func (ad *AliasDomain) Name() string

Name returns name.

func (*AliasDomain) SetTarget

func (ad *AliasDomain) SetTarget(target string) error

SetTarget sets the target.

func (*AliasDomain) Target

func (ad *AliasDomain) Target() string

Target returns target.

type AliasUser

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

AliasUser represents a AliasUser.

func NewAliasUser

func NewAliasUser(name string, targets []string) (*AliasUser, error)

NewAliasUser creates a new AliasUser instance.

func (*AliasUser) Name

func (au *AliasUser) Name() string

Name returns name.

func (*AliasUser) SetTargets

func (au *AliasUser) SetTargets(targets []string) error

SetTargets sets targets.

func (*AliasUser) Targets

func (au *AliasUser) Targets() []string

Targets returns targets.

type CatchAllUser

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

CatchAllUser represents a CatchAllUser.

func NewCatchAllUser

func NewCatchAllUser(name string) (*CatchAllUser, error)

NewCatchAllUser creates a new CatchAllUser instance.

func (*CatchAllUser) Name

func (cu *CatchAllUser) Name() string

Name returns name.

type Domain

type Domain struct {
	Users        []*User
	AliasUsers   []*AliasUser
	CatchAllUser *CatchAllUser
	// contains filtered or unexported fields
}

Domain represents a Domain.

func NewDomain

func NewDomain(name string) (*Domain, error)

NewDomain creates a new Domain instance.

func (*Domain) Disabled added in v0.0.4

func (d *Domain) Disabled() bool

Disabled returns true if the Domain is disabled.

func (*Domain) Name

func (d *Domain) Name() string

Name returns name.

func (*Domain) SetDisabled added in v0.0.4

func (d *Domain) SetDisabled(disabled bool)

SetDisabled disables the Domain if the input is true.

type Repository

type Repository struct {
	*RepositoryConfig
	// contains filtered or unexported fields
}

Repository represents a Repository.

func NewRepository

func NewRepository(c *RepositoryConfig) (*Repository, error)

NewRepository creates a new Repository instance.

func OpenRepository

func OpenRepository(basePath string) (*Repository, error)

OpenRepository opens a Repository and creates a new Repository instance.

func (*Repository) AliasDomain

func (r *Repository) AliasDomain(aliasDomainName string) (*AliasDomain, error)

AliasDomain returns a AliasDomain of the input name.

func (*Repository) AliasDomainCreate

func (r *Repository) AliasDomainCreate(aliasDomain *AliasDomain) error

AliasDomainCreate creates the input AliasDomain.

func (*Repository) AliasDomainRemove

func (r *Repository) AliasDomainRemove(aliasDomainName string) error

AliasDomainRemove removes a AliasDomain of the input name.

func (*Repository) AliasDomains

func (r *Repository) AliasDomains() ([]*AliasDomain, error)

AliasDomains returns a AliasDomain slice.

func (*Repository) AliasUser

func (r *Repository) AliasUser(domainName, aliasUserName string) (*AliasUser, error)

AliasUser returns a AliasUser of the input name.

func (*Repository) AliasUserCreate

func (r *Repository) AliasUserCreate(domainName string, aliasUser *AliasUser) error

AliasUserCreate creates the input AliasUser.

func (*Repository) AliasUserRemove

func (r *Repository) AliasUserRemove(domainName string, aliasUserName string) error

AliasUserRemove removes a AliasUser of the input name.

func (*Repository) AliasUserUpdate

func (r *Repository) AliasUserUpdate(domainName string, aliasUser *AliasUser) error

AliasUserUpdate updates the input AliasUser.

func (*Repository) AliasUsers

func (r *Repository) AliasUsers(domainName string) ([]*AliasUser, error)

AliasUsers returns a AliasUser slice.

func (*Repository) CatchAllUser

func (r *Repository) CatchAllUser(domainName string) (*CatchAllUser, error)

CatchAllUser returns a CatchAllUser that the input name has.

func (*Repository) CatchAllUserSet

func (r *Repository) CatchAllUserSet(domainName string, catchAllUser *CatchAllUser) error

CatchAllUserSet sets a CatchAllUser to the input Domain.

func (*Repository) CatchAllUserUnset

func (r *Repository) CatchAllUserUnset(domainName string) error

CatchAllUserUnset removes a CatchAllUser from the input Domain.

func (*Repository) Domain

func (r *Repository) Domain(domainName string) (*Domain, error)

Domain returns a Domain of the input name.

func (*Repository) DomainCreate

func (r *Repository) DomainCreate(domain *Domain) error

DomainCreate creates the input Domain.

func (*Repository) DomainRemove

func (r *Repository) DomainRemove(domainName string) error

DomainRemove removes a Domain of the input name.

func (*Repository) DomainUpdate added in v0.0.4

func (r *Repository) DomainUpdate(domain *Domain) error

DomainUpdate updates the input Domain.

func (*Repository) Domains

func (r *Repository) Domains() ([]*Domain, error)

Domains returns a Domain slice.

func (*Repository) GenerateConfigDovecot

func (r *Repository) GenerateConfigDovecot() string

GenerateConfigDovecot generate a configuration for Dovecot.

func (*Repository) GenerateConfigPostfix

func (r *Repository) GenerateConfigPostfix() string

GenerateConfigPostfix generate a configuration for Postfix.

func (*Repository) GenerateDatabases

func (r *Repository) GenerateDatabases() error

GenerateDatabases generates databases from the Repository.

func (*Repository) User

func (r *Repository) User(domainName, userName string) (*User, error)

User returns a User of the input name.

func (*Repository) UserCreate

func (r *Repository) UserCreate(domainName string, user *User) error

UserCreate creates the input User.

func (*Repository) UserRemove

func (r *Repository) UserRemove(domainName, userName string) error

UserRemove removes a User of the input name.

func (*Repository) UserUpdate

func (r *Repository) UserUpdate(domainName string, user *User) error

UserUpdate updates the input User.

func (*Repository) Users

func (r *Repository) Users(domainName string) ([]*User, error)

Users returns a User slice.

type RepositoryConfig

type RepositoryConfig struct {
	DirDatabasePath string `toml:"dir_database"`
	DirMailDataPath string `toml:"dir_maildata"`
	Username        string `toml:"username"`
	CmdPostalias    string `toml:"cmd_postalias"`
	CmdPostmap      string `toml:"cmd_postmap"`
}

RepositoryConfig is used to configure a Repository.

func DefaultRepositoryConfig

func DefaultRepositoryConfig() *RepositoryConfig

DefaultRepositoryConfig returns a RepositoryConfig with default parameter.

func (*RepositoryConfig) Normalize

func (c *RepositoryConfig) Normalize(rootPath string)

Normalize normalizes paramaters of the RepositoryConfig.

type User

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

User represents a User.

func NewUser

func NewUser(name, hashedPassword string, forwards []string) (*User, error)

NewUser creates a new User instance.

func (*User) Forwards

func (u *User) Forwards() []string

Forwards returns forwards.

func (*User) HashedPassword

func (u *User) HashedPassword() string

HashedPassword returns hashedPassword.

func (*User) Name

func (u *User) Name() string

Name returns name.

func (*User) SetForwards

func (u *User) SetForwards(forwards []string)

SetForwards sets forwards.

func (*User) SetHashedPassword

func (u *User) SetHashedPassword(hashedPassword string)

SetHashedPassword sets the hashed password.

Directories

Path Synopsis
cmd
mailfull
Command mailfull is a CLI application using the mailfull package.
Command mailfull is a CLI application using the mailfull package.

Jump to

Keyboard shortcuts

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