cf-email-cli
v1.0.0
Published
Cloudflare Email Routing CLI
Downloads
88
Readme
cf-email-cli
A Node.js CLI tool for managing Cloudflare Email Routing programmatically. Easily create, list, and delete email destinations and routing rules, as well as fetch required DNS records.
Features
- Create, list, and delete destination emails
- Create, list, and delete routing rules
- Show required DNS records for Cloudflare Email Routing
- Pretty-print tables for easy readability
- Fully scriptable for batch or automated tasks
Installation
# Install globally via npm
npm install -g cf-email-cliAfter installing, you can run
cf-emailanywhere in your terminal.
Environment Variables
Set these environment variables before using the CLI:
export CLOUDFLARE_TOKEN="your-api-token"
export CLOUDFLARE_ACCOUNT_ID="your-account-id"
export CLOUDFLARE_ZONE_ID="your-zone-id"CLOUDFLARE_TOKEN— API token with Email Routing permissionsCLOUDFLARE_ACCOUNT_ID— Cloudflare account IDCLOUDFLARE_ZONE_ID— Cloudflare zone ID for your domain
Usage
Create a destination email
cf-email create-destination -e [email protected]List all destination emails
cf-email list-destinationsDelete a destination email
cf-email delete-destination -i DEST_IDCreate a routing rule
cf-email create-rule -a [email protected] -d DEST_IDList routing rules
cf-email list-rulesDelete a routing rule
cf-email delete-rule -i RULE_IDShow required DNS records
cf-email dns-recordsExample Workflow
- Create a destination email:
cf-email create-destination -e [email protected]- Create an alias that forwards to that destination:
cf-email create-rule -a [email protected] -d DEST_ID- Verify DNS records:
cf-email dns-recordsBatch Alias Creation
You can script multiple aliases in one go with a shell loop or Node.js script:
for alias in info sales support; do
cf-email create-rule -a "[email protected]" -d DEST_ID
doneThis will create routing rules for info@, sales@, and support@ forwarding to the same destination.
Development
- CLI code is in
bin/cf-email.js - API wrappers in
lib/api.js - Pretty tables use cli-table3
- Commands use commander
Run locally with:
node bin/cf-email.js <command>Publishing
npm version patch
npm publishLicense
MIT © [Tom Tarpey]
