# Troubleshooting Fixes for common Mailflare setup and mail problems. Find your symptom below. ## Quick lookup | Problem | Cause | Fix | | --- | --- | --- | | [Error 9109: Invalid access token](#cloudflare-error-9109-invalid-access-token) | `CF_TOKEN` missing or wrong | Create a runtime token | | [Error 10000 on Email Routing](#cloudflare-error-10000-on-email-routing) | Token lacks permissions | Add the permissions | | [Error 2008, existing MX records](#cloudflare-error-2008-or-mx-records-for-another-mail-service) | Another service owns MX | Confirm replacement | | [D1 error 7404](#d1-error-7404-database-could-not-be-found) | Wrong database ID | Use your own ID | | [Resend or SES "not verified"](#resend-or-ses-domain-stays-not-verified) | DNS not seen yet or wrong | Check records | | [Resend key can only send](#resend-says-the-key-can-only-send-mail) | Sending-only key | Use a full-access key | | [SES receiving setup fails](#ses-receiving-setup-fails) | Region, URL, permissions | See table | | [Mail not arriving](#inbound-mail-is-not-arriving) | Routing or MX | Run the checklist | | [No password-reset email](#the-password-reset-email-never-arrives) | No recovery email or sender | Read Worker logs | | [Backups not running](#scheduled-backups-are-not-running) | Cron not deployed | `npm run deploy` | ## Cloudflare error 9109: Invalid access token The token that deploys the Worker is not available to Mailflare. Create a separate token and set it as `CF_TOKEN`. Verify it: ```bash curl "https://api.cloudflare.com/client/v4/user/tokens/verify" \ -H "Authorization: Bearer $CF_TOKEN" ``` Expect `success: true` and an active status. Check that: - `CF_TOKEN` holds the token secret, not its ID. - The value does not include `Bearer`. - The token is valid and its IP restrictions allow the Worker. - You redeployed after changing variables or secrets. For a legacy Global API Key, set `CF_EMAIL` and `CF_API_KEY` instead of `CF_TOKEN`. ## Cloudflare error 10000 on Email Routing The token must read the zone and manage its DNS, Email Routing settings and Email Routing rules. See the [`CF_TOKEN` permissions](deploy-cloudflare.md#1-create-cf_token). ## Cloudflare error 2008, or "MX records for another mail service" Only one service can own a domain's MX records. Mailflare shows the records it would replace and waits for your confirmation. > **Warning:** Confirming deletes those records. Your previous provider stops receiving mail for the domain. On Cloudflare, `CF_TOKEN` needs **DNS Edit** for this. ## D1 error 7404: Database could not be found `wrangler.jsonc` usually holds a database ID from another account. For a one-click deploy repository, remove `database_id` and keep `database_name`. Cloudflare then creates the database in your account. To run remote migrations later: 1. Open the Worker's **Settings → Bindings** page. 2. Open the `DB` binding and copy its database ID. 3. Add the ID to your local `wrangler.jsonc`. Do not commit it to a public repository. 4. Run the migrations: ```bash npm run db:migrate:remote ``` ## Resend or SES domain stays "not verified" The status comes from the provider, which checks public DNS. It can stay pending for several minutes. **Check status** asks again without creating anything. If one record stays stuck, check the per-record status under the domain, then look for: - A duplicate or old TXT record with the same name. - A proxied CNAME. It must be **DNS only**. - A doubled name, such as `send.example.com.example.com`. See what the public sees: ```bash dig TXT resend._domainkey.example.com +short ``` ## Resend says the key can only send mail A sending-only key cannot add domains or webhooks. Do one of: - Save a full-access key on the domain's Resend card. - Add the domain in the Resend dashboard yourself. For receiving, also create an `email.received` webhook to `/api/inbound/resend`. ## SES receiving setup fails | Problem | Cause | Fix | | --- | --- | --- | | Region rejected | SES receives mail only in some regions | Use one such as `us-east-1`, `us-west-2` or `eu-west-1` | | SNS cannot reach the app | `APP_URL` is not public HTTPS (localhost fails) | Set a public `APP_URL` | | Missing permissions | IAM policy incomplete | Attach the policy shown on the AWS card, then **Re-check** | | Can send only to verified addresses | SES sandbox | Request production access in the SES console | | Subscription pending | SNS has not called the endpoint yet | Wait a minute, then **Check again** | ## Inbound mail is not arriving For Cloudflare receiving, check that: 1. The Worker is named `mailflare`. 2. `services[].service` in `wrangler.jsonc` is also `mailflare`. 3. Email Routing is enabled for the domain. 4. The mailbox has a routing rule pointing to the Worker. For Resend or SES receiving, check that: 1. The receiving checklist is all green. 2. The MX record points to that provider. 3. `APP_URL` is a public HTTPS address. ## The password-reset email never arrives The form always reports success. Find one of these lines in the Worker logs: | Log line | Fix | | --- | --- | | `Password reset skipped: account has no recovery email` | Set a recovery email on the account | | `Password reset requested but no domain can send mail` | Enable sending on a domain with an active mailbox owned by an enabled user | | `Password reset request failed` | The provider rejected the message; read the error that follows | ## Scheduled backups are not running 1. Deploy the whole Worker. A local server or a source-only update does not create the cron trigger. ```bash npm run deploy ``` 2. Enable automatic backups under **Admin → Backups**. 3. Check the Worker has the `DB` and `BUCKET` bindings. ## Related - [Cloudflare deployment](deploy-cloudflare.md) - [Providers](providers.md) - [Self-hosting](deploy-docker.md)