mail_admin

Manage mail accounts of a split Dovecot/Postfix setup over SSH

Dovecot keeps the accounts in a passwd-file on the store host, Postfix accepts their addresses through a virtual_mailbox_maps hash table on the gateway host. Everything runs from your own computer over ssh and sudo; nothing needs to be installed on the servers.

Install

git clone https://git.streifling.com/jason/mail_admin.git ~/src/mail_admin
ln -s ~/src/mail_admin/mailuser ~/.local/bin/

Usage

mailuser add LOGIN      # create the account, accept mail for LOGIN@domain
mailuser passwd LOGIN   # set a new password
mailuser del LOGIN      # stop accepting mail, delete the account

sudo asks for your password once per host ("Your sudo password on HOST:"), and doveadm asks twice for the new mail password. Only prompts that wait for input end with a colon; the last line says what is true now.

The domain comes from postconf -h mydomain on the gateway. del keeps the mails on the store host and refuses while an alias in /etc/postfix/virtual still points to the address.

The mail client logs in with LOGIN, without the domain.

Config

The SSH hosts default to mini (store) and vps (gateway). Other names go into ~/.config/mailuser/config:

STORE_HOST=mail-store
GATEWAY_HOST=mail-gateway

Files changed on the servers

Host File Line
store /etc/dovecot/users LOGIN:{CRYPT}hash::::::
gateway /etc/postfix/vmailbox LOGIN@domain<TAB>OK, then postmap

Each file is only replaced after the new copy has the expected number of lines; the previous version stays next to it as .bak.

S
Description
Manage mail accounts of a split Dovecot/Postfix setup over SSH
Readme GPL-3.0
70 KiB
0 Stars 1 Watchers 0 Forks
Languages
Shell 100%