<commit_before>Mailu command line
==================

Managing users and aliases can be done from CLI using commands:

* alias
* alias-delete
* domain
* password
* user
* user-import
* user-delete
* config-dump
* config-update

alias
-----

.. code-block:: bash

  docker-compose exec admin flask mailu alias foo example.net "<EMAIL>,<EMAIL>"


alias-delete
------------

.. code-block:: bash

  docker-compose exec admin flask mailu alias-delete <EMAIL>


domain
------

.. code-block:: bash

  docker-compose exec admin flask mailu domain example.net


password
--------

.. code-block:: bash

  docker-compose exec admin flask mailu password myuser example.net '<PASSWORD>'


user
----

.. code-block:: bash

  docker-compose exec admin flask mailu user myuser example.net '<PASSWORD>'


user-import
-----------

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

  docker-compose run --rm admin flask mailu user-import myuser example.net '$6$51ebe0cb9f1dab48effa2a0ad8660cb489b445936b9ffd812a0b8f46bca66dd549fea530ce' 'SHA512-CRYPT'

user-delete
-----------

.. code-block:: bash

  docker-compose exec admin flask mailu user-delete <EMAIL>

config-dump
-----------

The purpose of this command is to dump domain-, relay-, alias- and user-configuration to a YAML template.
If you want to export non-hashed secrets you have to add the ``--secrets`` option.
Only non-default options are dumped. If you want to dump all options use ``--full``.

.. code-block:: bash

  docker-compose exec admin flask mailu config-dump > mail-config.yml

config-update
-------------

The purpose of this command is for importing domain-, relay-, alias- and user-configuration in bulk and synchronizing DB entries with an external YAML template.

.. code-block:: bash

  docker exec -i $(docker-compose ps -q admin) flask mailu config-update -nvd < mail-config.yml

*(The current version of docker-compose exec does not pass stdin correctly, so you have to user docker exec)*

mail-config.yml looks like:

.. code-block:: yaml
 
  domains:
    - name: example.com
      alternatives:
        - alternative.example.com

  users:
    - email: <EMAIL>
      password_hash: <PASSWORD>
      hash_scheme: MD5-CRYPT

  aliases:
    - email: <EMAIL>
      destination: "<EMAIL>,<EMAIL>"

  relays:
    - name: relay.example.com
      comment: test
      smtp: mx.example.com

You can use ``--dry-run`` to test your YAML without omitting any changes to the database.
With ``--verbose`` config-update will show exactly what it changes in the database.
Without ``--delete-object`` option config-update will only add/update new values but will *not* remove any entries missing in provided YAML input.

This is a complete YAML template with all additional parameters that could be defined:

.. code-block:: yaml

  aliases:
    - email: <EMAIL>
      comment: ''
      destination:
        - <EMAIL>
      wildcard: false
  
  domains:
    - name: example.com
      alternatives:
        - alternative.tld
      comment: ''
      dkim_key: ''
      max_aliases: -1
      max_quota_bytes: 0
      max_users: -1<commit_msg>small typo. Change 'omitting' to 'commiting'<commit_after>Mailu command line
==================

Managing users and aliases can be done from CLI using commands:

* alias
* alias-delete
* domain
* password
* user
* user-import
* user-delete
* config-dump
* config-update

alias
-----

.. code-block:: bash

  docker-compose exec admin flask mailu alias foo example.net "<EMAIL>,<EMAIL>"


alias-delete
------------

.. code-block:: bash

  docker-compose exec admin flask mailu alias-delete <EMAIL>


domain
------

.. code-block:: bash

  docker-compose exec admin flask mailu domain example.net


password
--------

.. code-block:: bash

  docker-compose exec admin flask mailu password myuser example.net '<PASSWORD>'


user
----

.. code-block:: bash

  docker-compose exec admin flask mailu user myuser example.net '<PASSWORD>'


user-import
-----------

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

  docker-compose run --rm admin flask mailu user-import myuser example.net '$6$51ebe0cb9f1dab48effa2a0ad8660cb489b445936b9ffd812a0b8f46bca66dd549fea530ce' 'SHA512-CRYPT'

user-delete
-----------

.. code-block:: bash

  docker-compose exec admin flask mailu user-delete <EMAIL>

config-dump
-----------

The purpose of this command is to dump domain-, relay-, alias- and user-configuration to a YAML template.
If you want to export non-hashed secrets you have to add the ``--secrets`` option.
Only non-default options are dumped. If you want to dump all options use ``--full``.

.. code-block:: bash

  docker-compose exec admin flask mailu config-dump > mail-config.yml

config-update
-------------

The purpose of this command is for importing domain-, relay-, alias- and user-configuration in bulk and synchronizing DB entries with an external YAML template.

.. code-block:: bash

  docker exec -i $(docker-compose ps -q admin) flask mailu config-update -nvd < mail-config.yml

*(The current version of docker-compose exec does not pass stdin correctly, so you have to user docker exec)*

mail-config.yml looks like:

.. code-block:: yaml
 
  domains:
    - name: example.com
      alternatives:
        - alternative.example.com

  users:
    - email: <EMAIL>
      password_hash: <PASSWORD>
      hash_scheme: MD5-CRYPT

  aliases:
    - email: <EMAIL>
      destination: "<EMAIL>,<EMAIL>"

  relays:
    - name: relay.example.com
      comment: test
      smtp: mx.example.com

You can use ``--dry-run`` to test your YAML without comitting any changes to the database.
With ``--verbose`` config-update will show exactly what it changes in the database.
Without ``--delete-object`` option config-update will only add/update new values but will *not* remove any entries missing in provided YAML input.

This is a complete YAML template with all additional parameters that could be defined:

.. code-block:: yaml

  aliases:
    - email: <EMAIL>
      comment: ''
      destination:
        - <EMAIL>
      wildcard: false
  
  domains:
    - name: example.com
      alternatives:
        - alternative.tld
      comment: ''
      dkim_key: ''
      max_aliases: -1
      max_quota_bytes: 0
      max_users: -1
{'fraction_non_alphanumeric': 0.11765610581359581, 'fraction_numerical': 0.014149492463857275, 'mean_word_length': 2.8916816277678037, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2674743', 'n_tokens_mistral': 2078, 'n_tokens_neox': 1901, 'n_words': 716}