Skip to main content
This guide helps you send your first email with the AhaSend CLI in a few minutes.

Prerequisites

Before you begin, make sure you have:
  1. Installed the AhaSend CLI
  2. An AhaSend account (sign up here)
  3. Your API key and Account ID from the dashboard
  4. A domain whose DNS records you can change. The examples use example.com; replace it with your domain.
The examples send with --sandbox, so no email is delivered. Step 4 explains sandbox mode.

Step 1: Authentication

First, authenticate with your AhaSend API credentials:
On a terminal, the command asks for:
  • Your API key, hidden as you type it
  • Your Account ID
The CLI checks that the key belongs to the account before it saves them. Profiles says which name the profile gets.
Your credentials are stored in ~/.ahasend/config.yaml for future use.
Alternatively, provide credentials directly:
Verify your authentication:

Step 2: Add a Sending Domain

Before sending emails, you need to add and verify a domain:
The command prints the DNS records the domain needs, on stderr, and marks each one as required or optional. Add them to your domain’s DNS settings. After configuring your DNS records, check them:
Most records verify within minutes. DNS changes can take up to 48 hours to propagate. Run ahasend domains check-dns again until the DNS is valid.

Step 3: Send Your First Email

Simple Text Email

HTML Email

Email with Both HTML and Text

Step 4: Test with Sandbox Mode

Before sending real emails, test your integration using sandbox mode:
Sandbox mode goes through the sending process but delivers nothing. See sandbox behavior.
You can also simulate different outcomes with --sandbox-result: deliver (the default), bounce, defer, fail, or suppress. It needs --sandbox.

Step 5: Send Batch Emails

Prepare Recipients File

Create a CSV file with recipient data (recipients.csv). The email and name columns set the recipient; each other column is a substitution:

Create an HTML File

Create the HTML content (welcome.html):

Send Batch Emails

The CLI:
  • Sends a personalized email to each recipient
  • Shows a progress bar on stderr, on a terminal only
  • Prints performance metrics on stderr after the send
  • Saves any failed recipients to a file in ~/.ahasend/ and prints its path, so you can pass it back to --recipients
  • Exits with code 0 only when every recipient was sent; exit codes lists the other codes

Step 6: Monitor Your Emails

Check Delivery Statistics

List Recent Messages

Common Patterns

Using Different Output Formats

Every failure exits with a nonzero code. JSON output describes what --output json prints, errors included, and stdout and stderr says where each part of the output goes.

Working with Multiple Environments

Profiles says which profile is the default; ahasend auth switch changes it.

Adding Attachments

Scheduling Emails

--schedule takes a relative time, such as 2h from now, or an RFC 3339 time. It must be in the future and at most 7 days ahead.

What’s Next?

Now that you’ve sent your first emails, explore more features:

Authentication

Learn about profiles and credential management

Message Commands

Explore all email sending options

Batch Processing

Send high-volume emails efficiently

Message Content

Personalize emails with substitutions

Getting Help

If you need help at any point:
For additional support: