The Cloudflare E-mail Routing Tool is a simple utility to manage and route e-mails using Cloudflare E-mail Routing Service. This tool is designed to streamline the process of creating e-mail addresses within your Cloudflare-managed domains.
- Python 3.10+
- Poetry
- Cloudflare account
- Ensure you have Python 3.10+ installed.
- Install Poetry if you haven't already:
pip install poetry
- Clone the repository and navigate to the project directory.
- Install the project dependencies using Poetry:
poetry install
- Run the main script with the desired service:
poetry run python emailrouting/main.py "Desired service"
-
Copy the
.env.example
file to create your own.env
file:cp .env.example .env
-
Open the
.env
file and fill in the required values based on your Cloudflare account and desired configuration. Here is an example:CLOUDFLARE_API_TOKEN=your_cloudflare_api_token CLOUDFLARE_ZONE_ID=your_cloudflare_zone_id
The script will create an e-mail address and output a confirmation message. For example:
E-mail created: [email protected]
Useful shell to add to your bash PATH
#!/bin/bash
ARG=$1
CURRENT_DIR=$(pwd)
cd /path/to/cloned/project || exit
poetry run python emailrouting/main.py "$ARG"
cd "$CURRENT_DIR" || exit
Add it to some place like /usr/local/bin
with a name like createemail
. Add execution permission:
$ sudo chmod +x /usr/local/bin/createemail
and then just call from anywhere:
$ createemail "The strage service asking my email"
This project uses ruff
for linting. To run the linter, use the following command:
poetry run ruff .