Skip to content
Nuits ReceiptsDocs
HomeSearch the docs, Ctrl KGitHubDark mode

Set up email

Route a receipt address to your Worker with Cloudflare Email Routing, allow your senders, and send a test receipt.

Updated

Use this guide to forward receipts to an address such as receipts@example.com and have them appear in the app. Email is optional: uploads work without it. The Deploy to Cloudflare button does not set up email, and neither does the app, because it holds no Cloudflare API token.

Prerequisites

  • A deployed copy of Nuits Receipts you can sign in to.
  • A domain on Cloudflare DNS. If the domain already receives mail somewhere else, use a subdomain such as receipts.example.com, so your existing MX records stay as they are.
  • The addresses you will forward receipts from, for example your own mailbox.

Route the address to the Worker

  1. Turn on Email Routing for the domain

    In the Cloudflare dashboard, go to Compute > Email Service > Email Routing and select Onboard Domain for your domain or subdomain. Cloudflare adds the MX, SPF and DKIM records it needs. Skip this step if Email Routing is already on.

  2. Create the routing rule

    On the Routing Rules tab, select Create routing rule and fill in:

    • Email pattern: the local part of your receipt address, for example receipts, and your domain.
    • Action: Send to a Worker.
    • Destination: your Nuits Receipts Worker (the Worker name you chose at deploy, my-nuits-receipts by default).

    Select Save. Only one rule should use this pattern: if two do, only the first one in the list is used.

  3. Tell the app the address and the allowed senders

    In the app, open Settings > Email and fill in Receipt address: the address you just routed. It is shown under the form on Add. Routing, not this field, decides what reaches the Worker. Once you change it, tick “I’ve added the Email Routing rule for this address” and press Save.

    Then open Settings > Email > Email senders, type each address you forward from in the address box and press Add. Mail from these addresses is read. Mail from anyone else waits in Receipts To do, as a New sender row, if Cloudflare’s checks prove who sent it.

    You can set the same values at deploy time with the RECEIPT_ADDRESS and ALLOWED_SENDER_EMAILS variables instead. A value saved in the app wins over the variable. See Change settings in the app.

  4. Send a test receipt

    From an allowed address, forward an email with a PDF or image receipt attached (or a receipt in the email body) to the receipt address.

Check it worked

Within a minute or so the receipt appears: in Receipts To do if anything needs a look, else on Home. The email itself is kept in your R2 bucket as the original.

If nothing appears:

  • The sender is not approved yet. Mail from anyone not on your allowed senders waits in Receipts To do as a New sender row. Press Allow to read it and anything else waiting from them; their later mail is read as it arrives.
  • The sender failed SPF. Mail from an allowed address must pass SPF in the result Email Routing records. A fail or softfail is dropped and logged as sender_auth_failed in the Worker’s logs.
  • The sender could not be proven. Mail with no usable result (for example SPF none with DKIM only) is kept, unread, with the flag Is this email genuine? It is not read by AI. Open it from Receipts To do, check the original, and select Read it if it is genuine.
  • The email was too big. Emails over 20 MiB are dropped and logged as email_too_large. At most 10 supported attachments per email are read; see Limits.

Change the address later

  1. In Cloudflare, add a Send to a Worker rule for the new address.
  2. In Settings > Email, change Receipt address, tick the confirmation and press Save. The app shows the next steps under “Now update Cloudflare Email Routing”.
  3. Send a test from an allowed address and check that it arrives.
  4. Remove the rule for the old address.

Type to search…

↑↓ navigate↵ selectEsc close