Skip to content

CLI

Initial config

If you installed python-mailcow for the first time you may run following command and change the settings according to your needs:

mailcow --create-example-config

After that you should be able to run commands like these:

  • mailcow alias get --all/--id 5
  • mailcow alias add --address moep@example.com --goto goto@example.com --no-active
  • mailcow alias delete --items 5

General help

mailcow --help
usage: test.py [-h] [--create-example-config] [--conf CONF] [--vertical] [--json] [--yaml] [--table] [--debug]
            {alias,app-passwd,bcc,dkim,dkim_duplicate,domain,domain-admin,da-acl,domain-policy,fwdhost,mailbox,oauth2-client,recipient_map,relayhost,resource,syncjob,tls-policy-map,transport,mailq,qitem,fail2ban,pushover,quarantine_notification,user-acl,logs,policy_bl_domain,policy_wl_domain,quarantine,rl-mbox,rl-domain,status,syncjobs,spam-score}
            ...

Interact with mailcows API.

positional arguments:
{alias,app-passwd,bcc,dkim,dkim_duplicate,domain,domain-admin,da-acl,domain-policy,fwdhost,mailbox,oauth2-client,recipient_map,relayhost,resource,syncjob,tls-policy-map,transport,mailq,qitem,fail2ban,pushover,quarantine_notification,user-acl,logs,policy_bl_domain,policy_wl_domain,quarantine,rl-mbox,rl-domain,status,syncjobs,spam-score}

optional arguments:
    -h, --help            show this help message and exit
    --create-example-config
                            Create configuration file
    --conf CONF, -c CONF  Defaults to: ~/.config/python-mailcow.conf
    --vertical, -v        Print (table) results vertically
    --json, -j            Print results as JSON
    --yaml, -y            Print results as YAML
    --table, -t           Print results as Table
    --debug, -d           Enable debugging

Help for specific subcommand

mailcow alias add --help
usage: mailcow alias add [-h] [--active] [--address ADDRESS] [--goto GOTO] [--goto_ham] [--goto_null] [--goto_spam] [--sogo_visible]

optional arguments:
    -h, --help            show this help message and exit
    --active, --no-active
                            is alias active or not
    --address ADDRESS     alias address, for catchall use "@domain.tld"
    --goto GOTO           destination address, comma separated
    --goto_ham, --no-goto_ham
                            learn as ham
    --goto_null, --no-goto_null
                            silently ignore
    --goto_spam, --no-goto_spam
                            learn as spam
    --sogo_visible, --no-sogo_visible
                            toggle visibility in SoGo

Edit alias

Editing alias' active status and visibility should look like this:

mailcow alias edit --items 78 --active --sogo_visible
+---------+----------------------------------------------------------------------------------------+-------------------------------------------+
|   type  |                                          log                                           |                    msg                    |
+---------+----------------------------------------------------------------------------------------+-------------------------------------------+
| success | ['mailbox', 'edit', 'alias', {'id': ['78'], 'active': '1', 'sogo_visible': '1'}, None] | ['alias_modified', 'example@example.com'] |
+---------+----------------------------------------------------------------------------------------+-------------------------------------------+

Last update: March 22, 2021