Product Update

Introducing Mailofly CLI: Send Emails from Your Terminal

Mailofly Team

Meet the Mailofly CLI: send emails from your terminal, manage domains and templates, trigger automations, and add email notifications to your CI/CD workflows.

You’re working in your terminal and need to send a test email, check a domain, or inspect an email API request. Now you can do all of that with Mailofly without leaving your development workflow.

The Mailofly CLI is our official command-line tool for sending emails and managing Mailofly from your terminal. It supports everyday development, scripts, AI agents, and CI/CD pipelines.

Here’s how to install it, send your first email, and use it in your projects.

Install the Mailofly CLI

Install the CLI globally with npm:

npm install -g @mailofly/cli

Or try it without a global installation:

npx @mailofly/cli --help

You can also use the installation scripts.

macOS and Linux:

curl -fsSL https://www.mailofly.com/install.sh | bash

Windows PowerShell:

irm https://www.mailofly.com/install.ps1 | iex

Once installed, explore the available commands:

mailofly --help

Connect your Mailofly account

Run the login command:

mailofly login

The CLI prompts for your API key using masked input, validates it against the Mailofly API, and saves it locally.

You can check your authentication status with:

mailofly whoami

For scripts and CI/CD pipelines, set the MAILOFLY_API_KEY environment variable. The CLI will use it without requiring an interactive login.

Send your first email from the terminal

Sending a transactional email takes one command:

mailofly emails send --from "Your App <hello@yourdomain.com>" --to you@example.com --subject "Hello from Mailofly CLI" --text "Your first email from the terminal."

Replace the sender with an address from your verified domain and the recipient with your own email address.

This is useful when checking your email integration before connecting it to the rest of your application. You can send a message directly, then inspect it using the CLI’s email and log commands.

Send HTML emails from a local file

If you already have an HTML email template in your project, send it using --html-file:

mailofly emails send --from "Your App <hello@yourdomain.com>" --to you@example.com --subject "Welcome to Your App" --html-file ./welcome.html

You can edit the file in your code editor and send another message to review the result in your inbox.

The CLI also supports saved Mailofly templates and dynamic variables, so you can work with reusable templates as well as local HTML.

For batch sending, provide a JSON file containing your email objects:

mailofly emails batch --file ./emails.json

A batch request supports up to 100 emails.

Manage domains and inspect email activity

The Mailofly CLI also helps with the setup and troubleshooting around email delivery.

List your connected domains:

mailofly domains list

Retrieve a domain and its DNS verification records:

mailofly domains get <domain-id>

After adding the required DNS records, trigger a verification check:

mailofly domains verify <domain-id>

Replace <domain-id> with the ID of your domain.

You can also review sent emails and recent API request logs:

mailofly emails list
mailofly logs list

When you need more detail, retrieve an individual record:

mailofly emails get <email-id>
mailofly logs get <log-id>

These commands give you a way to inspect activity while developing or investigating an issue.

Trigger email automations from the CLI

Mailofly Automations connects application events to email workflows. With the CLI, you can publish those events directly from your terminal.

For example, send a signup event using Bash or a compatible shell:

mailofly events send \
  --name user.signup \
  --contact you@example.com \
  --data '{"first_name":"Alex","plan":"starter"}'

The event name must match your automation’s trigger. An enabled workflow listening for user.signup can then use the supplied data for personalization and conditions.

This is useful for trying an onboarding sequence before adding event calls to your application.

You can also list workflows and inspect their execution history:

mailofly automations list
mailofly automations runs list <automation-id>

Add email notifications to CI/CD workflows

The CLI fits into deployment scripts and automated jobs.

Store your Mailofly API key in your CI provider’s secrets and expose it as MAILOFLY_API_KEY. Then run a send command after the relevant job succeeds:

npx @mailofly/cli emails send \
  --from "Deployments <deploy@yourdomain.com>" \
  --to team@yourdomain.com \
  --subject "Deployment completed" \
  --text "The latest release has been deployed."

Use your verified sending domain and your team’s recipient address.

You can use this pattern for deployment notifications, scheduled reports, or internal job updates.

Built for scripts and developer tools

The CLI displays readable output during interactive use and automatically switches to JSON when piped or run in a machine environment. You can request JSON explicitly with --json.

For an environment and connectivity check, run:

mailofly doctor

For structured diagnostic output:

mailofly doctor --json

The diagnostic checks cover your CLI version, API key, credential storage, and API validation.

The CLI also supports authentication profiles, making it easier to work across accounts or environments. To run a command with an existing production profile:

mailofly domains list --profile production

Beyond these examples, you can manage contacts, segments, templates, broadcasts, inbound emails, and webhook endpoints.

Get started with Mailofly CLI

Start by installing the CLI, connecting your account, and sending an email to yourself. From there, bring the commands you need into your local development and deployment workflows.

Read the Mailofly CLI documentation for the full command reference, or visit Mailofly to get started.



Written by

Mailofly Team

· September 30, 2026

The Mailofly Team is a group of builders, marketers, and automation-focused engineers dedicated to simplifying how businesses communicate through email. With a strong focus on deliverability, scalability, and real-world use cases, the team shares practical insights drawn directly from building and using Mailofly in production environments. Rather than theory, Mailofly content is rooted in execution—covering what actually works in cold outreach, campaign automation, and email infrastructure. From improving inbox placement to designing high-converting templates, the goal is simple: help you send smarter emails that get results. Whether you're a solo founder, a growing startup, or scaling outreach at volume, the Mailofly Team creates guides to help you move faster and avoid common mistakes.

Continue exploring guides and insights from the team.