-
Notifications
You must be signed in to change notification settings - Fork 1
Cloudflare Setup
github-actions[bot] edited this page Jul 7, 2026
·
2 revisions
Mailbox integrates directly with Cloudflare's Email Routing engine to programmatically manage incoming mailbox addresses on your custom domain.
External Sender
│ sends email to support@yourcompany.com
▼
Cloudflare Email Routing
│ matches routing rule for @yourcompany.com
▼
Cloudflare Worker Script (auto-deployed by Mailbox)
│ HTTP POST with MIME payload
▼
Mailbox Webhook: /api/emails/incoming
│ parsed, validated, persisted
▼
Dashboard shows the email in real-time ✅
Note
Receiving vs Sending: The Cloudflare integration is strictly for receiving inbound emails. To send emails (replies, outbound), configure your SMTP credentials separately in the .env file.
- A domain added and active on Cloudflare (orange cloud DNS).
- Email Routing must be enabled for the domain in your Cloudflare dashboard.
- Your Mailbox application must be deployed to a public HTTPS URL (cannot be localhost).
- Go to Cloudflare Dashboard → My Profile → API Tokens.
- Click Create Token → Create Custom Token.
- Give it a name (e.g.,
mailbox-token). - Add the following permissions:
| Resource | Permission |
|---|---|
| Zone — Zone Settings | Edit |
| Zone — Email Routing | Edit |
| Zone — Workers Scripts | Edit |
- Under Zone Resources, select Specific Zone → choose your domain.
- Click Continue to summary → Create Token.
- Copy the token immediately — it is only shown once.
- Log in to your Mailbox dashboard as an Admin or Owner.
- Navigate to Settings → Cloudflare Integration.
- Fill in:
- API Token — paste the token from Step 1.
-
Zone / Domain — select or type your domain (e.g.,
yourcompany.com). -
Webhook URL — your public application URL (e.g.,
https://mail.yourcompany.com).
- Click Link Domain.
Mailbox will automatically:
- Write a Cloudflare Worker script to forward MIME payloads to your webhook.
- Create the catch-all email routing rule for
*@yourcompany.com.
Once the domain is linked:
- Go to Settings → Mailbox Addresses.
- Click Add Address.
- Enter the address prefix (e.g.,
support,sales,hello). - Mailbox creates the routing rule in Cloudflare automatically.
Now any email sent to support@yourcompany.com will appear in the Mailbox dashboard.
To remove the Cloudflare integration:
- Go to Settings → Cloudflare Integration.
- Click Delink Domain.
This will remove the Worker script and routing rules from Cloudflare but will not delete your historical email data from the database.
| Issue | Solution |
|---|---|
| Emails not arriving | Check Cloudflare Email Routing is enabled on the domain |
| Worker deploy fails | Verify the API Token has Workers Scripts: Edit permission |
| Invalid webhook URL | Ensure the URL is HTTPS and publicly accessible |
403 on webhook |
Check that the webhook route is not behind auth middleware |