Getting Started with CLI

Prerequisite

Before getting started, verify that Java 11 or higher version is installed in your system irrespective of your OS (be it Mac, Windows, or Linux). 

Run the below command in your terminal to verify your system's current java version:

Copiedjava -version

Installation

To access the ZMail command line interface tool, you need to download the latest version of the tool in executable JAR file format. Once downloaded, save the JAR file to your system.

Note: 

This JAR file can be downloaded irrespective of the OS, provided Java 11 or higher version is already installed in your system.

Once the download is successful, you need to run the below command to install the tool.

Command

Copiedjava -jar zmail-cli.jar

Output

CopiedZMail CLI
? Enter your encryption password ****

You will be asked to enter an encryption password. This password is used to encrypt and decrypt the refresh tokens generated for your account before storing them in your machine.

Logging in to Zoho Mail 

The next step is to log in to your Zoho Mail account. Follow the below steps to log in:

  1. Open the command prompt and enter the below command to log in to your Zoho account:
     

Login command

Copiedzmail:>login

Output

CopiedAccess this url in your browser => https://accounts.zoho.com/oauth/v2/auth?client_id=****.A1TUVF0JPZUKSMNXAHNEZGJ8S6WF4U&redirect_uri=http://localhost****/oauth/callback&scope=ZohoMail.accounts.ALL,ZohoMail.organization.accounts.ALL,ZohoMail.messages.ALL,ZohoMail.attachments.ALL,ZohoMail.tags.ALL,ZohoMail.folders.ALL,ZohoMail.tasks.ALL,ZohoMail.notes.ALL,ZohoMail.links.ALL,ZohoMail.settings.ALL,ZohoMail.search.ALL,ZohoMail.organization.subscriptions.ALL,ZohoMail.organization.domains.ALL,ZohoMail.organization.policy.ALL,ZohoMail.organization.audit.ALL,ZohoMail.organization.groups.ALL,ZohoMail.partner.organization.ALL&response_type=code&access_type=offline&code_challenge_method=**************prompt=consent

2. By default, the tool uses zoho.com data center. You can replace the <DC> with the data center in which your organization's email account is hosted by using the below command.

login --dc <data_center>

You will be redirected to the login page of your selected DC account before proceeding. Refer to view the list of supported values for DC.

For example: To login to the IN DC, use the command:

Login to specific DC

Copiedzmail:>login --dc zoho.in

3. Copy and paste the login URL (that appears in the terminal/command prompt) in the browser window where you have already logged in with your Zoho account.

4. Click Accept on the consent page.
Accept permission

5. Once you approve the requested permissions, the CLI tool will complete the login automatically with "You have logged in successfully. Go back to the application." message, and stores your encrypted refresh token locally.

DC specific TLD values

Once you access the login URL, you will be redirected to the DC where your domain is hosted from. The supported DC specific TLD values for CLI are mentioned in the table below:

DC specific TLD values

Data Center

Value

US.com
India.in
Europe.eu
Australia.au
Japan.jp
Canada.ca
Saudi Arabia.sa