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/cliOr try it without a global installation:
npx @mailofly/cli --helpYou can also use the installation scripts.
macOS and Linux:
curl -fsSL https://www.mailofly.com/install.sh | bashWindows PowerShell:
irm https://www.mailofly.com/install.ps1 | iexOnce installed, explore the available commands:
mailofly --helpConnect your Mailofly account
Run the login command:
mailofly loginThe 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 whoamiFor 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.htmlYou 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.jsonA 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 listRetrieve 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 listWhen 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 doctorFor structured diagnostic output:
mailofly doctor --jsonThe 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 productionBeyond 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.


