Batch Processing

Send high-volume personalized emails efficiently using the AhaSend CLI batch processing capabilities.

Overview

Batch processing allows you to:
  • Send thousands of personalized emails
  • Use concurrent workers for speed
  • Track progress in real-time
  • Automatically retry failures
  • Generate performance metrics

Recipient File Formats

Create recipients.csv:
email,name,first_name,company,account_type
[email protected],John Doe,John,ACME Corp,premium
[email protected],Jane Smith,Jane,Tech Inc,basic
[email protected],Alice Johnson,Alice,StartUp Ltd,enterprise

Basic Batch Send

ahasend messages send \
  --from [email protected] \
  --recipients recipients.csv \
  --subject "Welcome to {{company}}" \
  --html-template welcome.html \
  --progress \
  --show-metrics

Performance Options

Concurrency Control

# Conservative (1 worker)
ahasend messages send \
  --recipients users.csv \
  --html-template template.html \
  --max-concurrency 1

# High performance (5 workers - default)
ahasend messages send \
  --recipients users.csv \
  --html-template template.html \
  --max-concurrency 5

# Maximum throughput (10 workers)
ahasend messages send \
  --recipients users.csv \
  --html-template template.html \
  --max-concurrency 10

Performance Comparison

ConcurrencyEmails/HourUse Case
1~3,600Testing, low priority
5~18,000Standard campaigns
10~36,000Maximum throughput

Progress Tracking

ahasend messages send \
  --recipients large-list.csv \
  --html-template newsletter.html \
  --max-concurrency 5 \
  --progress

Error Handling

Automatic Retries

ahasend messages send \
  --recipients users.csv \
  --html-template template.html \
  --max-retries 3

Failed Recipients Recovery

Failed recipients are automatically saved for retry:
# If failures occur, retry with saved file
ahasend messages send \
  --recipients ~/.ahasend/failed-2024-01-16-143022.json \
  --html-template campaign.html \
  --max-retries 5

Template Personalization

Global and Per-Recipient Data

// global-data.json
{
  "company_name": "ACME Corp",
  "support_email": "[email protected]"
}
ahasend messages send \
  --from [email protected] \
  --recipients users.csv \
  --subject "{{first_name}}, Welcome to {{company_name}}" \
  --html-template welcome.html \
  --global-substitutions global-data.json

Best Practices

1. Test with Small Batches First

# Test with first 10 recipients
head -11 recipients.csv > test-batch.csv

ahasend messages send \
  --from [email protected] \
  --recipients test-batch.csv \
  --html-template template.html \
  --sandbox

2. Use Idempotency Keys

ahasend messages send \
  --recipients users.csv \
  --html-template template.html \
  --idempotency-key "campaign-$(date +%Y%m%d)"

3. Monitor Performance

# Send with detailed logging
ahasend messages send \
  --recipients users.csv \
  --html-template template.html \
  --verbose \
  --show-metrics \
  --output json

Troubleshooting

Slow Performance: Increase --max-concurrency up to 10 workers High Failure Rate: Verify domains and check suppressions list Memory Issues: Process large files in smaller chunks

Next Steps