emailr-cli
v1.6.0
Published
Command-line interface for the Emailr email API
Maintainers
Readme
Emailr CLI
The official command-line interface for the Emailr email API. Send transactional emails, manage contacts, templates, domains, and more from your terminal.
Installation
npm (recommended)
npm install -g emailr-cliHomebrew (macOS/Linux)
brew install emailr-dev/tap/emailr-cliDirect Download
Download the latest binary for your platform from the releases page:
| Platform | Architecture | Download |
|----------|--------------|----------|
| macOS | Apple Silicon (M1/M2/M3) | emailr-macos-arm64 |
| macOS | Intel | emailr-macos-x64 |
| Linux | x64 | emailr-linux-x64 |
| Linux | ARM64 | emailr-linux-arm64 |
| Windows | x64 | emailr-windows-x64.exe |
After downloading:
# macOS/Linux
chmod +x emailr-*
sudo mv emailr-* /usr/local/bin/emailr
# Windows - move to a directory in your PATHVerify Installation
emailr --versionQuick Start
1. Configure your API key
emailr config set api-key YOUR_API_KEYOr set the environment variable:
export EMAILR_API_KEY=YOUR_API_KEY2. Send your first email
emailr send \
--to [email protected] \
--from [email protected] \
--subject "Hello from Emailr CLI" \
--html "<h1>Hello!</h1><p>This email was sent from the command line.</p>"Commands
Email Sending
# Send a simple email
emailr send --to [email protected] --from [email protected] --subject "Hello" --html "<p>Hi!</p>"
# Send with a template
emailr send --to [email protected] --from [email protected] --template TEMPLATE_ID --template-data '{"name": "John"}'
# Send with CC and BCC
emailr send --to [email protected] --from [email protected] --subject "Hello" --html "<p>Hi!</p>" --cc [email protected] --bcc [email protected]Contacts
# List contacts
emailr contacts list
# Create a contact
emailr contacts create --email [email protected] --first-name John --last-name Doe
# Get a contact
emailr contacts get CONTACT_ID
# Update a contact
emailr contacts update CONTACT_ID --first-name Jane
# Delete a contact
emailr contacts delete CONTACT_IDTemplates
# List templates
emailr templates list
# Create a template
emailr templates create --name "Welcome Email" --subject "Welcome {{name}}!" --html "<h1>Welcome {{name}}!</h1>"
# Get a template
emailr templates get TEMPLATE_ID
# Update a template
emailr templates update TEMPLATE_ID --subject "Updated: Welcome {{name}}!"
# Delete a template
emailr templates delete TEMPLATE_IDDomains
# List domains
emailr domains list
# Add a domain
emailr domains add example.com
# Get domain details
emailr domains get DOMAIN_ID
# Verify domain DNS
emailr domains verify DOMAIN_ID
# Check DNS status
emailr domains check-dns DOMAIN_ID
# Delete a domain
emailr domains delete DOMAIN_IDConfiguration
# Set API key
emailr config set api-key YOUR_API_KEY
# Set custom API URL
emailr config set api-url https://api.emailr.dev
# View current config
emailr config show
# Clear config
emailr config clearOutput Formats
All commands support --format option:
# JSON output (default for scripting)
emailr contacts list --format json
# Table output (default for interactive use)
emailr contacts list --format tableEnvironment Variables
| Variable | Description |
|----------|-------------|
| EMAILR_API_KEY | Your Emailr API key |
| EMAILR_BASE_URL | Custom API URL (default: https://api.emailr.dev) |
Configuration File
The CLI stores configuration in ~/.emailr/config.json:
{
"apiKey": "et_live_...",
"baseUrl": "https://api.emailr.dev"
}Examples
Send a welcome email to new users
#!/bin/bash
emailr send \
--to "$USER_EMAIL" \
--from "[email protected]" \
--template "welcome-template-id" \
--template-data "{\"name\": \"$USER_NAME\", \"activation_link\": \"$ACTIVATION_URL\"}"Bulk import contacts from CSV
#!/bin/bash
while IFS=, read -r email first_name last_name; do
emailr contacts create --email "$email" --first-name "$first_name" --last-name "$last_name"
done < contacts.csvCheck domain verification status
#!/bin/bash
DOMAIN_ID=$(emailr domains list --format json | jq -r '.[0].id')
emailr domains check-dns "$DOMAIN_ID" --format json | jq '.dkim.verified'Development
# Clone the repository
git clone https://github.com/emailr-dev/emailr.git
cd emailr
# Install dependencies
pnpm install
# Build the CLI
pnpm --filter emailr-cli build
# Run locally
node packages/sdks/cli/dist/index.js --helpLicense
MIT License - see LICENSE for details.
Support
- Documentation: https://docs.emailr.dev
- Issues: https://github.com/emailr-dev/emailr/issues
- Email: [email protected]
