# mail: Mail Accounts

The `mail` utility is used to manage domain mail service and mail names (email accounts) through CLI. By using this utility, you can perform the following tasks:

- enabling or disabling mail service on subscriptions
- creating and deleting mail accounts
- editing mail account settings
- managing mail groups associated with mail accounts

## Usage

    mail <command> [<mail_name>] [
    <option_1> [<param>]
    [<option_2> [<param>]]
    ... [<option_N> [<param>]]
    ]

## Example

The following command creates mail account JDoe@example.com, sets password mypass for it, sets the size of the email box to 50 MB, and enables the antivirus screening of both incoming and outgoing email messages for the mail account.

    plesk bin mail --create JDoe@example.com -passwd mypass -mbox_quota 50M -antivirus inout

## Commands

Command | Parameter | Description | Example
--- | --- | --- | ---
`--create` or `-c` | `<mail@domain>` | Creates a mail account. | To create the mail account JDoe@example.com:
    plesk bin mail --create JDoe@example.com
or
    plesk bin mail -c JDoe@example.com
`--update` or `-u` | `<mail@domain>` | Updates mail account settings. | To set the size of the mailbox for mail account JDoe@example.com to 50 MB:
    plesk bin mail --update JDoe@example.com -mbox_quota 50M
or
    plesk bin mail -u JDoe@example.com -mbox_quota 50M
`--update-service` | `<domain>` | Switches mail service on or off on a subscription. Requires the `-status` option. | To enable mail service on the subscription example.com:
    plesk bin mail --update-service example.com -status enabled
`--rename` | `<mail@domain>` | Renames a mail account. Required option `-new`. | To rename mail account JDoe@example.com to roy@example.com:
    plesk bin mail --rename JDoe@example.com -new roy
`--list` or `-l` |  | Retrieves the list of email accounts. | To see the list of email accounts:
    plesk bin mail -l
`--remove` or `-r` | `<mail@domain>` | Deletes a mail account. | To delete mail account JDoe@example.com:
    plesk bin mail --remove JDoe@example.com
or
    plesk bin mail -r JDoe@example.com
`--on` | `<domain>` | Enables email service on a subscription. | To enable email service on the subscription example.com:
    plesk bin mail --on example.com
`--off` | `<domain>` | Disables email service on a subscription. | To disable email service on the subscription example.com:
    plesk bin mail --off example.com
`--info` or `-i` | `<mail@domain>` | Displays information about a mail account. | To view information about mail account JDoe@example.com:
    plesk bin mail --info JDoe@example.com
or
    plesk bin mail -i JDoe@example.com
`--help` or `-h` |  | Displays help on the use of the utility. | To view help on the use of the utility:
    plesk bin mail --help
or
    plesk bin mail -h

## Options

Option | Parameter | Description | Example
--- | --- | --- | ---
`-manage-virusfilter` | `true|false` | Allows or prohibits managing the antivirus settings. | To allow managing the antivirus settings for the mail account JDoe@example.com:
    plesk bin mail -u JDoe@example.com -manage-virusfilter true
`-manage-spamfilter` | `true|false` | Allows or prohibits managing the spam filter settings. | To allow managing the spam filter settings for the mail account JDoe@example.com:
    plesk bin mail -u JDoe@example.com -manage-spamfilter true
`-mailbox` | `true|false` | Creates/Removes a mailbox. Is `false` by default. | To create mail box for a mail account JDoe@example.com:
    plesk bin mail -u JDoe@example.com -mailbox true
`-passwd` | `<password>` | Sets the user password. For additional comments, see the Note below the table. | To set the user password for the mail account JDoe@example.com to mypass:
    plesk bin mail -u JDoe@example.com -passwd mypass
`-passwd_type` | `plain|encrypted` | Specifies the type of user password. Ignored if no password is specified. | To set the user password to sample and password type to encrypted for the mail account JDoe@example.com:
    plesk bin mail -u JDoe@example.com -passwd_type encrypted -passwd '$1$3KWwrPxB$b6GLpDPpQVsljMRgAlQZG/'
`-mbox_quota` | `<number>[B|K|M|G|T]` | Sets the size of the mailbox. Default mailbox quota for a domain to which an account belongs, if set to `-1`. Is the default for the domain value by default. | To set the mailbox quota for the mail account JDoe@example.com to 50 MB:
    plesk bin mail -u JDoe@example.com -mbox_quota 50M
`-aliases` | `add|del:<alias>[,<alias_1>,...,<alias_N>` | Adds/Removes mail aliases. | To add mail aliases John and JohnDoe to mail account JDoe@example.com:
    plesk bin mail -u JDoe@example.com -aliases add:John,JohnDoe
`-mgroups` | `add|del:<alias>[,<alias_1>,...,<alias_N>` | Adds a mail account to or removes a mail account from a mail group. | To add mail account JDoe@example.com to the mail group testgroup:
    plesk bin mail -u JDoe@example.com -mgroups add:testgroup
`-forwarding` | `true|false` | Enables/disables mail forwarding for a mail account. If set to `true`, requires the `-forwarding-addresses` option. Is `false` by default. | To enable mail forwarding JDoe@example.com to JDoe@sample.com:
    plesk bin mail -u JDoe@example.com -forwarding true -forwarding-addresses add:JDoe@sample.com
`-forwarding-addresses` | `add|del: <address 1>, <address 2>` | Specifies e-mail addresses to which incoming mail should be forwarded. It is required when enabling the `-forwarding` option for a mail account. |
`-status` | `<enabled|disabled|admin, parent, client>` | Enables/disables mail service on a subscription depending on a parameter: `enabled` - the mail service is enabled `disabled` - the mail service is disabled `admin` - the mail service is disabled on behalf of the administrator `parent` - the status of the mail service is the same as the status of the subscription (e.g., if the subscription is disabled or suspended, the mail service is disabled; when the subscription becomes activated, the mail service will become enabled). `client` - the mail service is disabled on behalf of the customer who owns the subscription | To enable mail service on the subscription example.com:
    plesk bin mail --update-service example.com -status enabled
To disable mail service on the subscription example.com on behalf of the customer:
    plesk bin mail --update-service example.com -status client
In this case, if the administrator suspends the subscription and then activates it, the mail service will remain disabled.
`-new` | `<string>` | Specifies new mail account name. Used with `--rename` only. | To rename mail account JDoe@example.com to rroy@example.com:
    ./mail --rename JDoe@example.com -new rroy
`-description` | `<string>` | Specifies a description of an email address to be displayed in Plesk. | To create a description of the mail account JDoe@example.com:
    ./mail --update JDoe@example.com -description "A mailbox for JDoe"
`-json` |  | Displays the output in the JSON format. Used with the `--list` command. | To see the list of mail accounts in the JSON format:
    ./mail -l -json
`-antivirus` | `off|inout|in|out` | Disables (`off`) or enables (`in`, `out`, `inout`) antivirus screening of e-mail messages for a mail name. Sets the mode of antivirus screening: `in` - only incoming messages are screened `out` - only outgoing messages are screened `inout` - both incoming and outgoing messages are screened | To enable the antivirus screening for all incoming e-mail messages addressed to JDoe@example.com:
    plesk bin mail -u JDoe@example.com -antivirus in
`-cp-access` | `true|false` | Allows or prohibits logging in to the Control Panel with the specified email address as the username. This option, if ‘`true`’, creates an additional user with the specified email address as the user name and gives this user access to the Control Panel. To prohibit the corresponding existing user from logging in the the Control Panel, use ‘`false`’. | To create the mail account user4@ example.com and the additional user and to allow the user to log in to Control Panel with the email address as the user name and the password mypassword:
    plesk bin mail --create user4@example.com -passwd mypassword -cp-access true -mailbox true
To update the existing mail account user2@ example.com and create the additional user who can log in to Control Panel with the email address as the user name and the password mypass:
    plesk bin mail --update user2@example.com -passwd mypass -cp-access true -mailbox true
`-outgoing-messages-mbox-limit` | `<number>|default` | Sets the limit on outgoing messages from a mailbox (per hour). To set the Unlimited value, specify “-1”. Specify “default” to set the value specified in server-wide settings. | To set the limit on outgoing messages per hour from the email address JDoe@example.com:
    plesk bin mail --update JohnDoe@example.com -outgoing-messages-mbox-limit 12

Note

Use of the `-passwd` option is not recommended. Passing passwords through CLI as parameters of the `-passwd` option may potentially compromise the system’s security as command line can be observed by other users of the system. It is more secure to pass passwords through the environment variables. You can transfer non-encrypted passwords by using environment variable `PSA_PASSWORD` while using single quotes to specify the empty values in the command line for the argument of the `-passwd` option.

Similarly, you can transfer encrypted passwords through the environment variable `PSA_CRYPTED_PASSWORD` while using single quotes to specify the empty values in the command line for the argument of the `-passwd` option.