Integration guide · Updated October 2026
Give an n8n Workflow Its Own Email Inbox
Give your n8n workflow an address such as orders@yourdomain.com. Every email sent to it starts the workflow with the parsed message (sender, subject, text, HTML and attachments) through n8n's Webhook node, signed so you can trust it, and the workflow can reply from the same address. MarkRelay runs the mailbox in your own Cloudflare account; there is no IMAP polling and no Gmail account to share.
What you need
- MarkRelay deployed to your Cloudflare account, with your domain added.
- n8n Cloud or self-hosted n8n with a public URL.
1. Create the mailbox in MarkRelay
- In MarkRelay, create a mailbox for the workflow, such as
orders@yourdomain.com. - Make sure its Cloudflare Email Routing rule sends mail to the MarkRelay Worker (or that a catch-all does).
- Send it a test email and check it appears in webmail. Your team can keep using this mailbox in the browser while n8n works on the same mail.
2. Add a Webhook node in n8n
- Create a workflow and add a Webhook trigger node.
- Set HTTP Method to
POSTand give it a path such asmarkrelay-orders. - Under Options, turn on Raw Body, so the next step can check the signature against the exact bytes.
- Copy the Production URL and activate the workflow. Use the Test URL while you build.
3. Point a MarkRelay webhook at n8n
- Open Developer → Webhooks, select Add webhook and choose Custom endpoint.
- Paste the Webhook node's Production URL as the endpoint URL.
- Under Mailboxes, choose Specific mailboxes and pick only the workflow's mailbox.
- Add the webhook and copy the
whsec_...signing secret; it is shown once. - Select the pencil icon, then Send test. n8n should receive a signed
webhook.testevent.
From now on every message to that mailbox reaches n8n as an email.received event within seconds. Failed deliveries are retried up to 3 times. See inbound webhooks for the full payload.
4. Check the signature
Add a Code node after the Webhook node. It recomputes the HMAC-SHA256 of the timestamp and raw body with your signing secret, stops the workflow if it does not match, and outputs the parsed event:
// n8n Code node, "Run Once for All Items".
// Webhook node: HTTP Method POST, Options → Raw Body on.
const crypto = require('crypto');
const secret = 'whsec_...'; // or read it from a credential
const item = $input.first();
const raw = (await this.helpers.getBinaryDataBuffer(0, 'data')).toString('utf8');
const timestamp = item.json.headers['x-markrelay-timestamp'] ?? '';
const given = item.json.headers['x-markrelay-signature'] ?? '';
const expected = 'sha256=' + crypto.createHmac('sha256', secret)
.update(timestamp + '.' + raw)
.digest('hex');
if (given.length !== expected.length ||
!crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected))) {
throw new Error('Invalid MarkRelay signature');
}
return [{ json: JSON.parse(raw) }];Prefer no code? Use n8n's Crypto node with action Hmac, type SHA256, encoding hex on {{timestamp}}.{{raw body}}, then an IF node comparing sha256= plus the result with the x-markrelay-signature header.
5. Use the email in the workflow
The Code node outputs the event; the message is under data:
| Field | What it holds |
|---|---|
data.id | The email id; use it to dedupe and to reply |
data.mailbox | The MarkRelay mailbox it arrived in |
data.from.address, data.from.name | The sender |
data.subject | Subject line |
data.text, data.html | Plain-text and HTML bodies |
data.attachments[] | Each file's id, fileName, contentType and size |
data.threadId | The conversation it belongs to |
Route on data.subject with a Switch node, extract fields with an AI node, create a row in a sheet, or open a ticket. Skip events whose data.id you have already handled: delivery is at least once.
6. Reply from the same address
Add an HTTP Request node:
POST https://mail.yourdomain.com/openapi/v1/emails/{data.id}/reply
Authorization: Bearer sk-...
Content-Type: application/json
{ "text": "Thanks, we received your order." }Create the API key in Developer → API keys with Specific mailboxes scope and only the workflow's mailbox, so the workflow cannot read or send from any other address. Send exactly one of text, html or markdown; add "replyAll": true to answer everyone. The reply goes out from the same address, in the same thread, and shows up in webmail with an API badge. Download attachments with GET /attachments/{id} and the same key.
Common questions
How do I give an n8n workflow its own email address?
Create a mailbox such as orders@yourdomain.com in MarkRelay, add a Webhook node in n8n, and point a MarkRelay webhook scoped to that mailbox at the node's production URL. Every new message then starts the workflow with the parsed email.
Do I need the IMAP Email trigger?
No. MarkRelay pushes each new message to n8n's Webhook node as soon as it arrives, so n8n never polls a mailbox and needs no IMAP password.
Can the workflow reply from the same address?
Yes. Add an HTTP Request node that POSTs to /emails/{id}/reply on your MarkRelay API with a key scoped to the workflow's mailbox. The reply stays in the same thread.
Does the Code node allow require('crypto')?
On n8n Cloud, yes. On self-hosted n8n, allow it with the NODE_FUNCTION_ALLOW_BUILTIN=crypto environment variable, or verify with n8n's Crypto node (Hmac, SHA256, hex) instead.
Related: email to webhook, Zapier and Make guides, and the Email API reference.