How to install and use the official CLI for the Hostinger Mail API

Install and use the official Hostinger Mail API command-line interface to manage your emails directly from your terminal.

Updated 6 days ago

You can manage your Hostinger email accounts, messages, folders, webhooks, and quotas directly from your system terminal using the official command-line interface (CLI) tool. This official tool eliminates the need for writing custom scripts or handling HTTP requests manually.

This guide covers how to install the hostinger-mail CLI tool on macOS, Linux, and Windows, how to authenticate your account, and how to run basic commands.

Before you start

To use the Hostinger Mail API CLI tool, ensure you have the following:

  • An active Hostinger email account.
  • An API key generated from your Hostinger account panel.
  • A terminal environment on a supported operating system (Linux, macOS, or Windows).

Step 1 – Install the Hostinger Mail CLI

The installation method depends on the operating system you are using. Follow the instructions for your specific platform.

Option A – macOS (Homebrew)

If you are using macOS, you can install the tool using Homebrew.

  1. Open your terminal.
  2. Run the following command to tap the official repository and install the binary:

Bash

brew install hostinger/tap/hostinger-mail

Option B – Linux and Windows

For Linux and Windows, download the latest cross-platform binary directly from the official repository release page.

  1. Download the executable file corresponding to your operating system architecture.
  2. Place the binary file into a directory included in your system execution path (PATH variable) to run it from anywhere.

Step 2 – Authenticate with your API key

The tool requires API key authentication to safely connect to your mailbox services. You can configure your credentials using either a configuration file or environment variables.

Option A – Use a configuration file (Persistent)

  1. Create a configuration file in your home directory named
    .hostinger-mail.yaml.
  2. Open the file in a text editor and paste your token using the following format:
    YAML
    api_key: YOUR_API_KEY_HERE
  3. Save the file. The tool will automatically look for this file when executing operations.

Option B – Use environment variables (Temporary)

  1. Set the variable directly in your terminal session.
    1. On Linux and macOS, run:
      Bash
      export HOSTINGER_MAIL_API_KEY="YOUR_API_KEY_HERE"
    2. On Windows PowerShell, run:
      PowerShell
      $env:HOSTINGER_MAIL_API_KEY="YOUR_API_KEY_HERE"
Environment variables are temporary and will clear automatically when you close your current terminal window. Use the configuration file method for a permanent setup.

Step 3 – Manage your emails via commands

Once configured, each Mail API operation is accessible as a dedicated subcommand inside the terminal. The tool provides multiple output structures, including clean tables, raw JSON, and visual trees.

  1. To view a complete list of commands and global options, append the help flag to the tool:
    Bash
    hostinger-mail --help
  2. Run a specific subcommand to manage your mailbox resources. For example, to view your current usage limits:
    Bash
    hostinger-mail quota get
  3. To view folders or send a message, execute the respective operations:
    Bash
    hostinger-mail folders list
    
    hostinger-mail messages send --to="recipient@example.com" --subject="Terminal Test" --body="Sent via CLI."

Step 4 – Enable shell autocompletion (Optional)

You can enable shell auto-completion so that the command structure finishes automatically when you press the TAB key.

  1. Generate the autocompletion script for your specific shell environment (such as Bash, Zsh, fish, or PowerShell) by running the completion command:
    Bash
    hostinger-mail completion bash
  2. Follow the terminal instructions to append the generated script to your profile configuration file, then restart your terminal window.

You can now manage your Hostinger email settings, monitor webhooks, check data quotas, and process messages faster from your system command line.