Skip to content

difegam/mailtrap-cloudflare-dns

Repository files navigation

Mailtrap Cloudflare DNS

Table of Contents

About

A simple tool to add, update and delete Mailtrap DNS verification records in Cloudflare DNS.

Getting Started

Prerequisites

Creating a Cloudflare API token

To create a Cloudflare API token follow these steps:

  1. Go to https://dash.cloudflare.com/profile/api-tokens
  2. Click Create Token
  3. Click Create Custom Token at the bottom of the page
  • Give your API token a descriptive name mailtrap-verification-dns
  • Select the following permissions:
    • Zone - Zone - Read
    • Zone - DNS - Edit
  • Zone Resources
    • specific zone - select the zone you want to add the DNS record to
  1. Click Continue to Summary
  2. Click Create Token
  3. Copy the generated token
  4. Save the token in a secure place. You won't be able to see it again.

Creating a Mailtrap API token

To create a Mailtrap API token follow these steps:

  1. Go to https://mailtrap.io/api-tokens
  2. Copy the API token from the domain you want verification for.

Installing

Clone the repository and install the dependencies.

git clone git@github.com:difegam/mailtrap-cloudflare-dns.git
cd mailtrap-cloudflare-dns

Using uv

uv makes it easy to run the application. Install uv and run the following command. Can it be any simpler?

uv run app --help

The previous command will create a virtual environment, install Python version required for the project (Python 3.12) and the dependencies, and show the help message of the application.

Create a .env file in the root of the project with the following variables:

CLOUDFLARE_API_TOKEN=your-cloudflare-api-token
MAILTRAP_API_TOKEN=your-mailtrap-api-token
DOMAIN_NAME=example.com

If you don't want uv you can install the dependencies manually.

You must have Python 3.12 installed in your system.

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Activate the virtual environment and run the application.

source venv/bin/activate
python src/mailtrap_cloudflare_dns/main.py --help

Usage

Using the tool is simple.

uv run app --load-env --action {create, overwrite, delete}

use the --load-env flag to load the environment variables from the .env file. You can also use the --cloudflare-api-token, --mailtrap-api-token, and --domain-name flags to pass the values directly.

By default, the tool add a comment to all dns records to easily identify them on the Cloudflare dashboard. If you want to remove the comment, use the --comment "" to pass an empty string.

Nice to have

  • Add tests
  • Create a Docker image
  • Better error handling
  • Add more DNS providers

About

A simple tool to add, update and delete Mailtrap DNS verification records in Cloudflare DNS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy