2017-11-02 21:05:12 +02:00
Mailu command line
==================
Managing users and aliases can be done from CLI using commands:
* alias
2019-01-24 23:38:09 +02:00
* alias-delete
2019-02-13 11:53:40 +02:00
* domain
2019-07-08 10:35:59 +02:00
* password
2017-11-02 21:05:12 +02:00
* user
2019-01-24 23:38:09 +02:00
* user-import
* user-delete
* config-update
2021-02-15 01:46:59 +02:00
* config-export
* config-import
2017-11-02 21:05:12 +02:00
alias
-----
.. code-block :: bash
2018-11-08 22:35:41 +02:00
docker-compose exec admin flask mailu alias foo example.net "mail1@example.com,mail2@example.com"
2017-11-02 21:05:12 +02:00
2019-01-24 23:38:09 +02:00
alias-delete
2017-11-02 21:05:12 +02:00
------------
.. code-block :: bash
2019-01-24 23:38:09 +02:00
docker-compose exec admin flask mailu alias-delete foo@example.net
2017-11-02 21:05:12 +02:00
2019-02-13 11:53:40 +02:00
domain
2019-08-27 09:34:46 +02:00
------
2019-02-13 11:53:40 +02:00
.. code-block :: bash
docker-compose exec admin flask mailu domain example.net
2019-07-08 10:35:59 +02:00
password
--------
.. code-block :: bash
docker-compose exec admin flask mailu password myuser example.net 'password123'
2017-11-02 21:05:12 +02:00
user
----
.. code-block :: bash
2019-02-13 11:30:08 +02:00
docker-compose exec admin flask mailu user myuser example.net 'password123'
2017-11-02 21:05:12 +02:00
2019-01-24 23:38:09 +02:00
user-import
2017-11-02 21:05:12 +02:00
-----------
primary difference with simple `user` command is that password is being imported as a hash - very useful when migrating users from other systems where only hash is known.
.. code-block :: bash
2019-02-09 16:12:24 +02:00
docker-compose run --rm admin flask mailu user-import myuser example.net '$6$51ebe0cb9f1dab48effa2a0ad8660cb489b445936b9ffd812a0b8f46bca66dd549fea530ce' 'SHA512-CRYPT'
2017-11-02 21:05:12 +02:00
2019-01-24 23:38:09 +02:00
user-delete
2020-08-26 23:23:03 +02:00
-----------
2017-11-02 21:05:12 +02:00
.. code-block :: bash
2019-01-24 23:38:09 +02:00
docker-compose exec admin flask mailu user-delete foo@example.net
2017-11-02 21:05:12 +02:00
2021-02-15 01:46:59 +02:00
config-update
-------------
The sole purpose of this command is for importing users/aliases in bulk and synchronizing DB entries with external YAML template:
2020-08-26 23:23:03 +02:00
2021-02-15 01:46:59 +02:00
.. code-block :: bash
cat mail-config.yml | docker-compose exec -T admin flask mailu config-update --delete-objects
where mail-config.yml looks like:
2020-09-04 12:57:40 +02:00
.. code-block :: bash
2021-02-15 01:46:59 +02:00
users:
- localpart: foo
domain: example.com
password_hash: klkjhumnzxcjkajahsdqweqqwr
aliases:
- localpart: alias1
domain: example.com
destination: "user1@example.com,user2@example.com"
without `` --delete-object `` option config-update will only add/update new values but will *not* remove any entries missing in provided YAML input.
Users
2021-02-16 16:36:01 +02:00
^^^^^
2021-02-15 01:46:59 +02:00
following are additional parameters that could be defined for users:
* comment
* quota_bytes
* global_admin
* enable_imap
* enable_pop
* forward_enabled
* forward_destination
* reply_enabled
* reply_subject
* reply_body
* displayed_name
* spam_enabled
* spam_threshold
Alias
2021-02-16 16:36:01 +02:00
^^^^^
2021-02-15 01:46:59 +02:00
additional fields:
2020-09-04 12:57:40 +02:00
2021-02-15 01:46:59 +02:00
* wildcard
2020-09-04 12:57:40 +02:00
2021-02-15 01:46:59 +02:00
config-export
-------------
2021-02-16 16:36:01 +02:00
The purpose of this command is to export the complete configuration in YAML or JSON format.
2021-02-15 01:46:59 +02:00
.. code-block :: bash
2020-09-04 12:57:40 +02:00
2021-02-16 16:36:01 +02:00
$ docker-compose exec admin flask mailu config-export --help
2020-10-24 22:32:08 +02:00
2021-02-15 01:46:59 +02:00
Usage: flask mailu config-export [OPTIONS] [FILTER]...
2020-09-04 12:57:40 +02:00
2021-02-15 01:46:59 +02:00
Export configuration as YAML or JSON to stdout or file
Options:
-f, --full Include attributes with default value.
-s, --secrets Include secret attributes (dkim-key, passwords).
-d, --dns Include dns records.
2021-02-19 19:01:02 +02:00
-c, --color Force colorized output.
2021-02-15 01:46:59 +02:00
-o, --output-file FILENAME Save configuration to file.
-j, --json Export configuration in json format.
-?, -h, --help Show this message and exit.
Only non-default attributes are exported. If you want to export all attributes use `` --full `` .
If you want to export plain-text secrets (dkim-keys, passwords) you have to add the `` --secrets `` option.
2020-10-24 22:32:08 +02:00
To include dns records (mx, spf, dkim and dmarc) add the `` --dns `` option.
2021-02-19 19:01:02 +02:00
2021-02-15 01:46:59 +02:00
By default all configuration objects are exported (domain, user, alias, relay). You can specify
filters to export only some objects or attributes (try: `` user `` or `` domain.name `` ).
2021-02-19 19:01:02 +02:00
Attributes explicitly specified in filters are automatically exported: there is no need to add `` --secrets `` or `` --full `` .
2020-08-26 23:23:03 +02:00
.. code-block :: bash
2021-02-19 19:01:02 +02:00
$ docker-compose exec admin flask mailu config-export --output mail-config.yml
2020-08-26 23:23:03 +02:00
2021-02-19 19:01:02 +02:00
$ docker-compose exec admin flask mailu config-export domain.dns_mx domain.dns_spf
$ docker-compose exec admin flask mailu config-export user.spam_threshold
2020-10-24 22:32:08 +02:00
2021-02-15 01:46:59 +02:00
config-import
2017-11-02 21:05:12 +02:00
-------------
2021-02-16 16:36:01 +02:00
This command imports configuration data from an external YAML or JSON source.
2017-11-02 21:05:12 +02:00
2020-09-04 12:57:40 +02:00
.. code-block :: bash
2021-02-16 16:36:01 +02:00
$ docker-compose exec admin flask mailu config-import --help
2020-09-04 12:57:40 +02:00
2021-02-15 01:46:59 +02:00
Usage: flask mailu config-import [OPTIONS] [FILENAME|-]
2020-09-04 12:57:40 +02:00
2021-02-15 01:46:59 +02:00
Import configuration as YAML or JSON from stdin or file
2020-09-04 12:57:40 +02:00
2021-02-15 01:46:59 +02:00
Options:
-v, --verbose Increase verbosity.
-s, --secrets Show secret attributes in messages.
-q, --quiet Quiet mode - only show errors.
-c, --color Force colorized output.
-u, --update Update mode - merge input with existing config.
-n, --dry-run Perform a trial run with no changes made.
-?, -h, --help Show this message and exit.
2020-09-04 12:57:40 +02:00
The current version of docker-compose exec does not pass stdin correctly, so you have to user docker exec instead:
2017-11-02 21:05:12 +02:00
.. code-block :: bash
2021-02-15 01:46:59 +02:00
docker exec -i $(docker-compose ps -q admin) flask mailu config-import -nv < mail-config.yml
2017-11-02 21:05:12 +02:00
2021-02-15 01:46:59 +02:00
mail-config.yml contains the configuration and looks like this:
2020-08-26 23:23:03 +02:00
.. code-block :: yaml
2021-02-15 01:46:59 +02:00
domain:
2020-08-26 23:23:03 +02:00
- name: example.com
alternatives:
- alternative.example.com
2017-11-02 21:05:12 +02:00
2021-02-15 01:46:59 +02:00
user:
2020-08-26 23:23:03 +02:00
- email: foo@example.com
2021-02-15 01:46:59 +02:00
password_hash: '$2b$12$...'
2017-11-02 21:05:12 +02:00
hash_scheme: MD5-CRYPT
2021-02-15 01:46:59 +02:00
alias:
2020-08-26 23:23:03 +02:00
- email: alias1@example.com
2021-02-15 01:46:59 +02:00
destination:
- user1@example.com
- user2@example.com
2017-11-02 21:05:12 +02:00
2021-02-15 01:46:59 +02:00
relay:
2020-08-26 23:23:03 +02:00
- name: relay.example.com
comment: test
smtp: mx.example.com
2017-11-02 21:05:12 +02:00
2021-06-08 09:09:07 +02:00
config-import shows the number of created/modified/deleted objects after import.
2021-02-15 01:46:59 +02:00
To suppress all messages except error messages use `` --quiet `` .
2021-02-19 19:01:02 +02:00
By adding the `` --verbose `` switch the import gets more detailed and shows exactly what attributes changed.
2021-02-16 16:36:01 +02:00
In all log messages plain-text secrets (dkim-keys, passwords) are hidden by default. Use `` --secrets `` to log secrets.
If you want to test what would be done when importing without committing any changes, use `` --dry-run `` .
2021-06-08 09:09:07 +02:00
By default config-import replaces the whole configuration. `` --update `` allows to modify the existing configuration instead.
2021-02-16 16:36:01 +02:00
New elements will be added and existing elements will be modified.
It is possible to delete a single element or prune all elements from lists and associative arrays using a special notation:
+-----------------------------+------------------+--------------------------+
| Delete what? | notation | example |
+=============================+==================+==========================+
| specific array object | `` - -key: id `` | `` - -name: example.com `` |
+-----------------------------+------------------+--------------------------+
| specific list item | `` - -id `` | `` - -user1@example.com `` |
+-----------------------------+------------------+--------------------------+
| all remaining array objects | `` - -key: null `` | `` - -email: null `` |
+-----------------------------+------------------+--------------------------+
| all remaining list items | `` - -prune- `` | `` - -prune- `` |
+-----------------------------+------------------+--------------------------+
The `` -key: null `` notation can also be used to reset an attribute to its default.
To reset *spam_threshold* to it's default *80* use `` -spam_threshold: null `` .
2017-11-02 21:05:12 +02:00
2021-02-19 19:01:02 +02:00
A new dkim key can be generated when adding or modifying a domain, by using the special value
`` dkim_key: -generate- `` .
2021-02-15 01:46:59 +02:00
This is a complete YAML template with all additional parameters that can be defined:
2017-11-02 21:05:12 +02:00
2020-08-26 23:23:03 +02:00
.. code-block :: yaml
2021-02-15 01:46:59 +02:00
domain:
2020-08-26 23:23:03 +02:00
- name: example.com
alternatives:
- alternative.tld
comment: ''
dkim_key: ''
max_aliases: -1
max_quota_bytes: 0
max_users: -1
signup_enabled: false
2021-02-15 01:46:59 +02:00
user:
2020-08-26 23:23:03 +02:00
- email: postmaster@example.com
comment: ''
displayed_name: 'Postmaster'
enable_imap: true
enable_pop: false
enabled: true
fetches:
- id: 1
comment: 'test fetch'
2021-02-15 01:46:59 +02:00
error: null
2020-08-26 23:23:03 +02:00
host: other.example.com
2021-02-15 01:46:59 +02:00
keep: true
last_check: '2020-12-29T17:09:48.200179'
2020-08-26 23:23:03 +02:00
password: 'secret'
2021-02-15 01:46:59 +02:00
hash_password: true
2020-08-26 23:23:03 +02:00
port: 993
protocol: imap
tls: true
2021-02-15 01:46:59 +02:00
username: fetch-user
2020-08-26 23:23:03 +02:00
forward_destination:
- address@remote.example.com
forward_enabled: true
forward_keep: true
global_admin: true
manager_of:
- example.com
2021-02-15 01:46:59 +02:00
password: '$2b$12$...'
hash_password: true
2020-08-26 23:23:03 +02:00
quota_bytes: 1000000000
reply_body: ''
reply_enabled: false
2021-02-15 01:46:59 +02:00
reply_enddate: '2999-12-31'
reply_startdate: '1900-01-01'
2020-08-26 23:23:03 +02:00
reply_subject: ''
spam_enabled: true
spam_threshold: 80
tokens:
- id: 1
comment: email-client
ip: 192.168.1.1
2021-02-15 01:46:59 +02:00
password: '$5$rounds=1$...'
aliases:
- email: email@example.com
comment: ''
destination:
- address@example.com
wildcard: false
2017-11-02 21:05:12 +02:00
2021-02-15 01:46:59 +02:00
relay:
- name: relay.example.com
comment: ''
smtp: mx.example.com