Prerequisites
Before you begin, make sure you have:- Installed the AhaSend CLI
- An AhaSend account (sign up here)
- Your API key and Account ID from the dashboard
- A domain whose DNS records you can change. The examples use
example.com; replace it with your domain.
--sandbox, so no email is delivered. Step 4 explains sandbox mode.
Step 1: Authentication
First, authenticate with your AhaSend API credentials:- Your API key, hidden as you type it
- Your Account ID
Step 2: Add a Sending Domain
Before sending emails, you need to add and verify a domain: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.
--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
- 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
--output json prints, errors included, and stdout and stderr says where each part of the output goes.
Working with Multiple Environments
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

