For the complete documentation index, see llms.txt. This page is also available as Markdown.

CLI app

Mailtrap CLI is a command-line tool for accessing Mailtrap features that allow you to send emails, inspect sandbox inboxes, monitor deliverability stats, and administer domains, templates, contacts, and more, all from your terminal.

Link to official GitHub documentation.

How it works

Installation

To install Mailtrap CLI app, choose one of the following installation methods:

  • Homebrew (macOS / Linux):

brew install mailtrap/cli/mailtrap
  • Download binary

Download the latest release from GitHub Releases and add it to your PATH.

  • Go install:

go install github.com/mailtrap/mailtrap-cli@latest

Authentication

To validate your token, detect your account ID, and save both to ~/.mailtrap.yaml run the following command:

mailtrap configure --api-token YOUR_TOKEN

Or, you can also use environment variables:

export MAILTRAP_API_TOKEN=your-token

Using the CLI

Then use any of the ~87 commands across 20 resource groups. A few examples:

Every command supports --output json for scripting and CI/CD integration. Shell completion is available for Bash, Zsh, Fish, and PowerShell.

Use case examples

Test before you send

Here's how you can verify your email renders correctly in sandbox before sending to real users.

1

Create a project for your sandbox

To create a project for your sandbox and get a project ID, use the following command:

2

Create a sandbox inside your project

Next, use the following command to create a sandbox and get a sandbox ID:

3

Send a test email to sandbox

Then, simply send the email, just like so:

4

Inspect the email

To list the sandboxes, use:

Then, to get a spam score, use the following command:

Or, to inspect the HTML:

Replace [MESSAGE-ID] with the actual message ID that you get after sending an email to your sandbox.

Email marketing – build and send a campaign

You can also send an email marketing campaign from the Mailtrap CLI app, covering everything from managing contacts to creating email templates. Here's how:

1

Create a contact list

2

Add a custom field

3

Add contacts to the list

4

Create an email template

5

Launch the email campaign

Analytics – monitor email performance

Once you start sending emails, use the Mailtrap CLI app to track delivery, opens, clicks across categories and providers, and more.

1

Overall stats

2

Break down by email category

3

See which email providers deliver best

4

Drill into recent individual emails

5

List your suppressed recipients

Last updated

Was this helpful?