iredmail-cli
iredmail-cli copied to clipboard
A command line interface to interact with iredMail (MYSQL edition)
iredmail-cli
Table of contents
- Table of contents
- Installation
-
Overview
- Mailbox
- Mailbox-alias
- Forwarding
- Alias
-
Commands
-
mailbox
- add [MAILBOX_EMAIL] [PLAIN_PASSWORD]
- delete [MAILBOX_EMAIL]
- info [MAILBOX_EMAIL]
- list
- update [MAILBOX_EMAIL]
- add-alias [ALIAS] [MAILBOX_EMAIL]
- delete-alias [ALIAS_EMAIL]
-
forwarding
- add [MAILBOX_EMAIL] [DESTINATION_EMAIL]
- delete [MAILBOX_EMAIL] [DESTINATION_EMAIL]
- list
-
domain
- add [DOMAIN]
- delete [DOMAIN]
- list
- add-alias [ALIAS_DOMAIN] [DOMAIN]
- delete-alias [ALIAS_DOMAIN]
- add-catchall [DOMAIN] [DESTINATION_EMAIL]
- delete-catchall [DOMAIN] [DESTINATION_EMAIL]
-
alias
- add [ALIAS_EMAIL]
- delete [ALIAS_EMAIL]
- info [ALIAS_EMAIL]
- list
- add-forwarding [ALIAS_EMAIL] [DESTINATION_EMAIL]
- delete-forwarding [ALIAS_EMAIL] [DESTINATION_EMAIL]
- version
-
mailbox
Installation
The current version only supports the MySQL version of iRedMail
Download the appropriate binary from https://github.com/drlogout/iredmail-cli/releases/latest, untar the file and move the binary to e.g. /usr/local/bin/iredmail-cli
.
By default iredmail-cli
expects a config file under ~/.my.cnf-vmailadmin
. This file is generated through the iRedMail installation. It's also possible to specify a config file with the —config
flag.
The .my.cnf-vmailadmin
file needs following variables:
[client]
host=127.0.0.1 (optional, default 127.0.0.1)
port=3306 (optional, default 3306)
user=vmailadmin
password="UXXjQYn3KLbAJhonbkmNyGNJRsoXZ4rn"
Overview
Mailbox
What is called user
in iRedMail is a mailbox
in the iredmail-cli terminology. I don't know if this is a good idea, but for me user feels wrong.
iRedMail:
[email protected] = user
iredmail-cli:
[email protected] = mailbox
See mailbox
Mailbox-alias
A mailbox can have additional email addresses:
All emails sent to the addresses [email protected]
and [email protected]
will be delivered to the same mailbox [email protected]
.
Emails can now also be sent with [email protected]
and [email protected]
as sender.
See mailbox add-alias [ALIAS] [MAILBOX_EMAIL]
Forwarding
Mails can be forwarded from a mailbox:
All emails sent to the mailbox [email protected]
will also be delivered to the addresses [email protected]
and [email protected]
.
See forwarding
Alias
If no mailbox is required, an alias can be used to forward emails to other addresses:
Multiple destination addresses are possible.
alias
Commands
To print the help of a command or sub command append the —help
or -h
flag.
mailbox
Add/delete/list mailboxes and mailbox-aliases.
add [MAILBOX_EMAIL] [PLAIN_PASSWORD]
Add a new mailbox.
Example:
$ iredmail-cli mailbox add [email protected] swekjhlwekjdhw
Flags:
-q, --quota: Set custom quota in MB, default 2048
-s, --storage-path: Set custom storage path
delete [MAILBOX_EMAIL]
Delete a mailbox.
Example:
$ iredmail-cli mailbox delete [email protected]
Flags:
-f, --force: Force deletion
info [MAILBOX_EMAIL]
Show mailbox info.
Example:
$ iredmail-cli mailbox info [email protected]
+----------------------+---------------------------------------------+
| MAILBOX | [email protected] |
+----------------------+---------------------------------------------+
| Quota | 2048 MB |
| Maildir | example.com/i/n/f/info-2018.07.09.09.13.27/ |
+----------------------+---------------------------------------------+
list
List mailboxes.
Example:
$ iredmail-cli mailbox list
+-----------------------+------------+
| MAILBOX | QUOTA (MB) |
+-----------------------+------------+
| [email protected] | 2048 |
| [email protected] | 2048 |
| [email protected] | 2048 |
| [email protected] | 2048 |
+-----------------------+------------+
# To filter results use the --filter flag
$ iredmail-cli mailbox list -f example.com
+-----------------------+------------+
| MAILBOX | QUOTA (MB) |
+-----------------------+------------+
| [email protected] | 2048 |
| [email protected] | 2048 |
+-----------------------+------------+
Flags:
-f, --filter: Filter results
update [MAILBOX_EMAIL]
Update keep-copy and quota.
keep-copy: If mailboxes with forwardings should not keep a copy of the forwarded email use "--keep-copy no".
This is only possible if at least one forwarding for [MAILBOX_EMAIL] exists.
By default copies are kept in the mailbox.
quota: The quota of the mailbox could be set with this flag, e.g. "--quota 4096" (in MB).
Example:
$ iredmail-cli mailbox update [email protected] -k no
$ iredmail-cli mailbox update [email protected] -q 4098
Flags:
-k, --keep-copy: enable or disable keep-copy
-q, --quota: Set custom quota in MB
add-alias [ALIAS] [MAILBOX_EMAIL]
Add a mailbox alias.
A mailbox [email protected]
can have additional email addresses like [email protected]
, [email protected]
and more, all emails sent to these addresses will be delivered to the same mailbox ([email protected]
). Emails can now also be sent with those addresses as sender.
Example:
$ iredmail-cli mailbox add-alias abuse [email protected]
$ iredmail-cli mailbox add-alias webmaster [email protected]
$ iredmail-cli mailbox info [email protected]
+----------------------+---------------------------------------------+
| MAILBOX | [email protected] |
+----------------------+---------------------------------------------+
| Quota | 2048 MB |
| Mailbox aliases | abuse |
| | webmaster |
| Maildir | example.com/i/n/f/info-2018.07.09.09.13.27/ |
+----------------------+---------------------------------------------+
delete-alias [ALIAS_EMAIL]
Delete an alias.
Example:
$ iredmail-cli mailbox delete-alias [email protected]
forwarding
Add/delete/list forwardings.
add [MAILBOX_EMAIL] [DESTINATION_EMAIL]
Add forwarding.
Example:
$ iredmail-cli forwarding add [email protected] [email protected]
$ iredmail-cli forwarding add [email protected] [email protected]
$ iredmail-cli mailbox info [email protected]
+----------------------+---------------------------------------------+
| MAILBOX | [email protected] |
+----------------------+---------------------------------------------+
| Quota | 2048 MB |
| Mailbox aliases | abuse |
| | webmaster |
| Forwardings | [email protected] |
| | [email protected] |
| Keep copy in mailbox | yes |
| Maildir | example.com/i/n/f/info-2018.07.09.09.13.27/ |
+----------------------+---------------------------------------------+
By default a copy will be left in the mailbox, to change that behavior use the iredmail-cli mailbox update
command.
delete [MAILBOX_EMAIL] [DESTINATION_EMAIL]
Delete forwarding.
Example:
$ iredmail-cli forwarding delete [email protected] [email protected]
list
List forwardings.
Example:
$ iredmail-cli forwarding list
+------------------+----------------------------+----------------------+
| MAILBOX EMAIL | DESTINATION EMAIL | KEEP COPY IN MAILBOX |
+------------------+----------------------------+----------------------+
| [email protected] | [email protected] | yes |
| | [email protected] | |
| [email protected] | [email protected] | no |
+------------------+----------------------------+----------------------+
Flags:
-f, --filter: Filter results
domain
Add/delete/list domains, domain aliases and catchall forwardings.
add [DOMAIN]
Add a domain.
Example:
$ iredmail-cli domain add somedomain.com
Flags:
-d, --description: Domain description
-s, --settings: Domain settings (default: default_user_quota:2048)
delete [DOMAIN]
Delete a domain.
Example:
$ iredmail-cli domain delete somedomain.com
Flags:
-f, --force: Force deletion
list
List domains.
Example:
$ iredmail-cli domain list
+-------------+-----------+-------------------+-------------+
| DOMAIN | ALIAS | CATCH-ALL ADDRESS | DESCRIPTION |
+-------------+-----------+-------------------+-------------+
| domain.com | | | |
| example.com | | | |
+-------------+-----------+-------------------+-------------+
Flags:
-f, --filter: Filter results
add-alias [ALIAS_DOMAIN] [DOMAIN]
Add an alias domain.
Emails sent to user@[ALIAS_DOMAIN] will be delivered to user@[DOMAIN].
Example:
$ iredmail-cli domain add-alias domain.net domain.com
$ iredmail-cli domain list
+-------------+------------+-------------------+-------------+
| DOMAIN | ALIAS | CATCH-ALL ADDRESS | DESCRIPTION |
+-------------+------------+-------------------+-------------+
| domain.com | domain.net | | |
| example.com | | | |
+-------------+------------+-------------------+-------------+
delete-alias [ALIAS_DOMAIN]
Delete an alias domain.
Example:
$ iredmail-cli domain delete-alias [ALIAS_DOMAIN]
add-catchall [DOMAIN] [DESTINATION_EMAIL]
Add a per-domain catch-all forwarding.
Emails sent to non-existing mailboxes of [DOMAIN] will be delivered to [DESTINATION_EMAIL].
Multiple [DESTINATION_EMAIL]s are possible.
Example:
$ iredmail-cli domain add-catchall example.com [email protected]
$ iredmail-cli domain add-catchall example.com [email protected]
$ iredmail-cli domain list
+-------------+------------+----------------------+-------------+
| DOMAIN | ALIAS | CATCH-ALL ADDRESS | DESCRIPTION |
+-------------+------------+----------------------+-------------+
| domain.com | domain.net | | |
| example.com | | [email protected] | |
| | | [email protected] | |
+-------------+------------+----------------------+-------------+
delete-catchall [DOMAIN] [DESTINATION_EMAIL]
Delete a per-domain catch-all forwarding.
Example:
$ iredmail-cli domain delete-catchall example.com [email protected]
alias
Add/delete/list aliases and their forwardings.
add [ALIAS_EMAIL]
Add an alias.
Emails sent to [ALIAS_EMAIL] will be delivered to alias forwardings.
Use the "alias add-forwarding" command to add forwardings to the alias.
An alias can have multiple forwardings.
Example:
$ iredmail-cli alias add [email protected]
delete [ALIAS_EMAIL]
Delete an alias.
Example:
$ iredmail-cli alias delete [email protected]
Flags:
-f, --force: Force deletion
info [ALIAS_EMAIL]
Show alias info.
Example:
$ iredmail-cli alias info [email protected]
+--------------------+---------------------------+
| ALIAS | FORWARDINGS |
+--------------------+---------------------------+
| [email protected] | [email protected] |
| | [email protected] |
| | [email protected] |
+--------------------+---------------------------+
list
List aliases.
Example:
$ iredmail-cli alias list
+-----------------------+---------------------------+
| ALIAS | FORWARDINGS |
+-----------------------+---------------------------+
| [email protected] | |
| [email protected] | |
+-----------------------+---------------------------+
Flags:
-f, --filter: Filter results
add-forwarding [ALIAS_EMAIL] [DESTINATION_EMAIL]
Add forwarding to an alias.
Emails sent to [ALIAS_EMAIL] will be delivered to [DESTINATION_EMAIL].
An alias can have multiple forwardings.
Example:
$ iredmail-cli alias add [email protected] [email protected]
$ iredmail-cli alias add [email protected] [email protected]
+-----------------------+---------------------------+
| ALIAS | FORWARDINGS |
+-----------------------+---------------------------+
| [email protected] | [email protected] |
| | [email protected] |
+-----------------------+---------------------------+
delete-forwarding [ALIAS_EMAIL] [DESTINATION_EMAIL]
Delete forwarding from an alias.
Example:
$ iredmail-cli alias delete [email protected] [email protected]
version
Show iredMail and iredmail-cli version.
Example:
$ iredmail-cli version
cli version: 0.2.5
iredMail version (MySQL): 0.9.8