Mail Accounts: mail Utility CLI command line

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

  • Enabling or disabling mail service on a domain
  • Creating and deleting mail names
  • Editing mail name settings
  • Managing mail groups associated with mail names
  • Managing mail user control panel access
  • Managing mail user control panel display parameters

Syntax

mail <command> [<mail name>] [

<option_1> [<param>]

[<option_2> [<param>]]

…[<option_N> [<param>]]

]

Example

The following command line creates mail name admin@example.com, enables Plesk control panel access for the mail user with login name admin@example.com, sets password userpass for the mail user to access the control panel, sets the size of the e-mail box to 50 MB, and enables the Dr.Web antivirus screening of both incoming and outgoing e-mail messages for the mail name.

# ./mail –create admin@example.com -cp-access true -passwd userpass -mbox_quota 50MB -drweb inout

Commands

Command

Parameter

Description

Example

--create or -c

<e-mail address>

Creates a Plesk mail name (an e-mail account).

To create a Plesk mail name example.com:

# ./mail -create admin@example.com

or

# ./mail -c admin@example.com

--update or -u

<e-mail address>

Updates mail name settings.

To set the size of the e-mail box to 50 MB for mail name admin@example.com:

# ./mail –update admin@example.com -mbox_quota 500

or

# ./mail -u admin@example.com -mbox_quota 50M

--update-service

<domain name>

Updates mail service status on a domain.

Requires concomitant use of the -statusoption.

To enable mail service on domain example.com:

# ./mail –update-service example.com -status enabled

--remove or -r

<e-mail address>

Deletes a mail name from Plesk.

To delete mail name admin@example.com from Plesk:

# ./mail –remove admin@example.com

or

# ./mail -r admin@example.com

--on

<domain name>

Enables e-mail service on a domain.

To enable e-mail service on domain example.com:

# ./mail –on example.com

--off

<domain name>

Disables e-mail service on a domain.

To disable e-mail service on domain example.com:

# ./mail –off example.com

--info or -i

<e-mail address>

Displays information about a mail name.

To display information about Plesk mail name admin@example.com:

# ./mail –info admin@example.com

or

# ./mail –i admin@example.com

--help or -h

Displays help on the use of the utility.

To display help on the use of the autoresponder utility:

# ./mail –help

or

# ./mail –h

Options

Option

Parameter

Description

Example

-cp_access

true | false

Enables or disables mail name user to Plesk control panel (the Control panel accessparameter).

Set to true by default.

To enable access to control panel for user of mail name admin@example.com:

# ./mail -u admin@example.com -cp_access true

-mailbox

true | false

Creates or deletes mail box for a mail name.

To delete mail box for a mail name admin@example.com:

# ./mail -u admin@example.com -mailbox false

-passwd

<password>

Sets the user password for a mail name.

For additional comments, see the Note below the table.

To change user password to userpass for mail name admin@example.com:

# ./mail -u admin@example.com -passwd userpass

-passwd_type

plain|encrypted

Specifies the type of user password. Ignored if no password is specified.

For additional comments, see the Note below the table.

To set the type of user password to encrypted for mail name admin@example.com:

# ./mail -u admin@example.com -passwd_type encrypted

-mbox_quota

<number>[K|M|G]

Sets the size of the mail box for a mail name. Type-1 to set the parameter to the default mail box size value set for the domain to which the mail name belongs (the Default for the domainparameter).

Set to the Default for the domainvalue by default.

To set the size of the mail box for a mail name admin@example.com to 50 MB:

# ./mail -u admin@example.com -mbox_quota 50M

-aliases

add|del:<alias>[,<alias 1>,...,<alias N>

Adds to or deletes e-mail aliases from a mail name.

To add e-mail aliases serveradmin and webadmin mail aliases to mail name admin@example.com:

# ./mail -u admin@example.com -aliases add:webadmin,serveradmin

-mgroups

add|del:<mail group>[,<mail group 1>,...,<mail group N>

Adds to or removes a mail name from Plesk mail groups (Groups).

To remove admin@example.com from mail groups Partners and VIPs:

# ./mail -u admin@example.com -mgroups del:Partners,VIPs

-redirect

true | false

Enables or disables redirecting mail messages for a mail name (Redirect).

If set to true, requires concomitant use of the -rediraddroption.

To enable redirecting e-mail messages for mail name admin@example.com to e-mail address traveladmin@example.com:

# ./mail -u admin@example.com -redirect true -rediaddr admin@example.com@redirect.com

-rediraddr

<e-mail address>

Specifies an e-mail address to which incoming mail for a mail name will be forwarded upon receipt.

To set up redirecting mail for mail name admin@example.com to e-mail address traveladmin@example.net:

# ./mail -u admin@example.com -redirect true -rediaddr traveladmin@example.net

-group

true | false

Enables or disables a mail group associated with a mail name.

To enable mail group associated with mail name admin@example.com:

# ./mail -u admin@example.com -group enable

-groupmem

add|del:<e-mail address>[,<e-mail address 1>,...,<e-mail address N>

Adds to or removes e-mail addresses from a mail group associated with a mail name.

To add e-mail addresses admin@example.net and admin@example.org to the mail group associated with mail name admin@example.com:

# ./mail -u admin@example.com -groupmem add:admin@example.net,admin@example.org

-multiple-sessions

true | false

Allows multiple simultaneous sessions under mail user’s login (the Allow multiple sessionsparameter).

To allow multiple sessions to run simultaneously under mail user login admin@example.com :

# ./mail -u admin@example.com -multiple-sessions true

-locale

<language code>

Sets the default interface language for mail user’s control panel (theInterface languageparameter). The argument of the command must be a valid four-letter language code derived from the language code described in ISO-639-2 and the corresponding country code described in ISO-3166. For example, the Plesk code for the Italian language code is it-IT; the Plesk code for the American variant of English is en-US; the Plesk code for the British variant of English is en-GB.

To set the default interface language for mail user with login name admin@example.com to Russian:

# ./mail -u admin@example.com -locale -ru-RU

-max-button-length

<number>

Sets the maximum allowed button length (in symbols) for mail user’s control panel (the Button label lengthparameter).

To change the button label length to 20 for the control panel for the mail user with login name admin@example.com:

# ./mail -u admin@example.com -max-button-length 20

-lock-screen

true | false

Sets the Prevent users from working with the control panel until interface screens are completely loadedparameter.

To prevent mail user with login name admin@example.com from working with the control panel until control panel screens are completely loaded:

# ./mail -u admin@example.com -lock-screen true

-skin

<skin name>

Sets the default interface skin for mail user’s control panel (theInterface skinparameter).

To set the WinXP Olivegreen skin as the default interface skin for the mail user with login name admin@example.com:

# ./mail -u admin@example.com -skin "WinXP Olivegreen"

-status

enabled | disabled | admin, domadm, parent, client

Enables or disables mail service on a domain (theenabled ordisabledparameters, respectively). Disables domain mail service and sets the domain mail service status to Domain mail service is disabled by administrator(admin) orDomain mail service is disabled by client(client). Sets the domain mail service status to the status of the domain (parent). The use of thedomadmparameter is restricted; the parameter should not be used for changing the domain mail service status.

To enable mail service on domain example.com:

# ./mail –update-service example.com -status enabled

To set the status of mail service on domain example.com to the status of the domain:

./domain –update-service example.com -status parent

-manage-drweb

true | false

Enables or disables Dr.Web antivirus application management by a mail user (theDr.Web antivirus managementpermission).

To enable management of the Dr.Web antivirus application by the mail user with login name admin@example.com:

# ./mail -u admin@example.com -manage-drweb true

-manage-spamfilter

true | false

Enables or disables spam filter management by a mail user (theSpam filter managementpermission).

To enable spam filter management by the mail user with login name admin@example.com:

# ./mail -u admin@example.com -manage-spamfilter true

-drweb

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 by Dr.Web:

in – only incoming messages are screened

out – only outgoing messages are screened

inout – both incoming and outgoing messages are screened

To enable the Dr.Web antivirus screening for all incoming e-mail messages addressed to mail name admin@example.com:

# ./mail -u admin@example.com -antivirus in

Note: Use of this 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 -passwd_type options.
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 and -passwd_type options.

Leave a comment