> ## Site index
> Every page on this site is listed at https://mailkube.com/llms.txt.

> ## Agent instructions
> This site presents mailkube, a service that sends transactional email over a REST API or SMTP.
> Customer data is stored in the European Union.
> Read the developer documentation at https://docs.mailkube.com, which publishes its own llms.txt.
> Take prices and plan volumes from https://mailkube.com/pricing.md, never from a comparison page or a blog post.
> Read the legal documents at their HTML address.
> Every published version of the terms, privacy policy and data processing addendum is kept byte for byte under /legal/<document>/<sha256>/.
> Quote the checked-on date that a comparison page prints with its competitor figures.
> When this site does not state a price, limit or capability, say so instead of guessing.

# Send your first email with Cloudflare Auto Setup

> Send your first email from a new domain without touching your DNS panel. Auto Setup verifies it on Cloudflare, then curl, Python and Go send it.

Source: https://mailkube.com/blog/send-first-email-cloudflare-auto-setup/

November 23, 2026


*The welcome email this tutorial sends, open in Logs. Addresses, the IP and the identifiers are examples.*


This tutorial sends your first email from a domain mailkube has never seen. `hello@notify.example.com` welcomes `jordan@example.com`, and the Logs view shows the message accepted, handed over and delivered. The DNS records come from one click on Cloudflare, so you never copy a DKIM key by hand.

## Prerequisites

- A mailkube account. The [Free plan](/pricing/) sends 4,000 emails a month (140 a day) from unlimited domains.
- A domain whose DNS is hosted on Cloudflare.
- Python 3.12 or later, or Go 1.23 or later, for the SDK sections. The curl section needs nothing.

Every example uses `notify.example.com`. Replace it with your own sending domain.

## Add the domain

In the dashboard, open the domain switcher and pick **Create Domain**. Add a subdomain rather than your apex: the [docs' own example](https://docs.mailkube.com/docs/domains) is `mail.yourcompany.com`, and a subdomain keeps this traffic apart from whatever your main domain already sends.

![The Add your domain form with notify.example.com entered](https://cdn.mailkube.com/blog/send-first-email-cloudflare-auto-setup/add-domain.png)

The domain starts in onboarding, where sending is refused. Two steps take it to active: verify the domain, then create a credential for it.

## Let Auto Setup write the records on Cloudflare

The domain page lists the records to publish, with an **Auto Setup** button above them. Click it and mailkube sends you to Cloudflare in a new tab.

![The Auto Setup dialog: you go to Cloudflare, approve the changes, and come back verified](https://cdn.mailkube.com/blog/send-first-email-cloudflare-auto-setup/auto-setup.png)

Cloudflare shows the four records before anything is written:

![Cloudflare asking to authorize four DNS records from mailkube for notify.example.com](https://cdn.mailkube.com/blog/send-first-email-cloudflare-auto-setup/cloudflare-authorize.png)

| Record | Name | What it does |
| --- | --- | --- |
| TXT | `kube1._domainkey.notify` | DKIM public key. mailkube generated the pair and keeps the private half. |
| TXT | `_dmarc.notify` | DMARC policy `p=none`, with reports sent to mailkube. Failures get reported, nothing gets rejected. |
| MX | `mkube-send.notify` | Return path. Bounces come back here. |
| TXT | `mkube-send.notify` | SPF, checked on the return path. |

SPF is checked on `mkube-send`, the subdomain your mail is actually sent from, so the SPF record on your main domain stays exactly as it is. Adding a second sender usually means editing that record; here you don't. [What each of the three records proves](/blog/spf-dkim-dmarc/) has its own guide.

The authorization is one-time and does not let mailkube change your zone later. It adds records and removes none. Click **Authorize**, and you land back on the domain page while verification runs.

![Your domain is verified](https://cdn.mailkube.com/blog/send-first-email-cloudflare-auto-setup/domain-verified.png)

If your DNS lives somewhere else, copy each Host and Value from the domain page into your provider, then click **Verify**. Verification keeps running in the background if you close the dialog, since propagation can take a few minutes.

## Create an API key

Open **Credentials**, then **API keys**, and create one. A key is bound to a single verified domain, and its secret is shown once.

![API key ready, with the secret shown once](https://cdn.mailkube.com/blog/send-first-email-cloudflare-auto-setup/api-key-ready.png)

Put it in your environment, where both SDKs look for it:

```bash
export MAILKUBE_API_KEY='mk_...'
```

## Send your first email with curl

```bash
curl -X POST https://api.mailkube.com/mta/v1/emails \
  -H "Authorization: Bearer $MAILKUBE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme <hello@notify.example.com>",
    "to": "jordan@example.com",
    "subject": "Welcome to Acme",
    "html": "<h1>Welcome</h1><p>Your account is ready.</p>"
  }'
```

```json
{
  "id": "3f9a7c21-5b6e-4d0a-9c8e-2b7f1e4d6a90",
  "message_id": "<3f9a7c21-5b6e-4d0a-9c8e-2b7f1e4d6a90@msg.mailkube.com>"
}
```

A `200` means the message is queued; delivery happens asynchronously. `id` is mailkube's identifier, the one webhook events carry. `message_id` is the RFC Message-ID header the recipient's copy will have.

## Send it from Python

```bash
pip install mailkube
```

```python
from mailkube import Mailkube

client = Mailkube()  # reads MAILKUBE_API_KEY

email = client.emails.send(
    from_="Acme <hello@notify.example.com>",
    to="jordan@example.com",
    subject="Welcome to Acme",
    html="<h1>Welcome</h1><p>Your account is ready.</p>",
    text="Welcome\n\nYour account is ready.",
)

print(email.id, email.message_id)
```

The parameter is `from_` because `from` is a Python keyword; the SDK sends it as `from`. Passing both `html` and `text` gives clients that refuse HTML something to show.

## Send it from Go

```bash
go get github.com/mailkube/mailkube-go
```

```go
package main

import (
	"context"
	"errors"
	"log"

	"github.com/mailkube/mailkube-go"
)

func main() {
	client, err := mailkube.New() // reads MAILKUBE_API_KEY
	if err != nil {
		log.Fatal(err)
	}

	email, err := client.Emails.Send(context.Background(), mailkube.SendEmailParams{
		From:    "Acme <hello@notify.example.com>",
		To:      []string{"jordan@example.com"},
		Subject: "Welcome to Acme",
		HTML:    "<h1>Welcome</h1><p>Your account is ready.</p>",
	})
	if err != nil {
		var apiErr *mailkube.APIError
		if errors.As(err, &apiErr) {
			log.Fatalf("%s: %s (request %s)", apiErr.ErrorName, apiErr.Message, apiErr.RequestID)
		}
		log.Fatal(err)
	}
	log.Println(email.ID, email.MessageID)
}
```

Build the client once and share it: it is safe across goroutines. Log `RequestID` on every failure, because it is the value support asks for.

## Find it in Logs

Open **Logs** and click the row. The panel at the top of this post is what you get: **Delivered**, and **API** because the message came through the REST API (an SMTP send says SMTP). Auth is your key being checked, Reception is the message accepted for one recipient, and Delivery quotes the receiving server's reply word for word.

Opens and clicks do not show up yet. Open and click tracking are per-domain settings, and both start off.

## Troubleshooting

| Error | Cause | Fix |
| --- | --- | --- |
| `403 invalid_api_key` | The key is missing, wrong, or limited to source IPs your machine is not on. mailkube reports every authentication problem under this one name on purpose. | Check the key and its restrictions in Credentials. |
| `422 from_domain_not_allowed` | The `from` address is on a domain other than the one the key is bound to, such as `hello@example.com` with a key for `notify.example.com`. | Send from the key's domain, or create a key for the other one. |
| `400 missing_user_agent` | A bare HTTP client sent no `User-Agent`. curl and the SDKs always send one. | Set a `User-Agent` that names your integration. |

## Where to go next

The message is delivered, but your app only knows it was queued. Next week's post wires up a webhook receiver for `email.delivered`, `email.bounced` and the rest, with signature checks in Node, Python and Go. Until then, [Sending your first email](https://docs.mailkube.com/docs/sending-your-first-email) covers attachments, custom headers and templates.

