Socket
Book a DemoInstallSign in
Socket

cf-email-cli

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cf-email-cli

Cloudflare Email Routing CLI

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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-cli

After installing, you can run cf-email anywhere 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 permissions
  • CLOUDFLARE_ACCOUNT_ID — Cloudflare account ID
  • CLOUDFLARE_ZONE_ID — Cloudflare zone ID for your domain

Usage

Create a destination email

cf-email create-destination -e me@mydomain.com

List all destination emails

cf-email list-destinations

Delete a destination email

cf-email delete-destination -i DEST_ID

Create a routing rule

cf-email create-rule -a alias@mydomain.com -d DEST_ID

List routing rules

cf-email list-rules

Delete a routing rule

cf-email delete-rule -i RULE_ID

Show required DNS records

cf-email dns-records

Example Workflow

  • Create a destination email:
cf-email create-destination -e support@mydomain.com
  • Create an alias that forwards to that destination:
cf-email create-rule -a help@mydomain.com -d DEST_ID
  • Verify DNS records:
cf-email dns-records

Batch 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 "$alias@mydomain.com" -d DEST_ID
done

This 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 publish

License

MIT © [Tom Tarpey]

FAQs

Package last updated on 13 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts