Receive inbound email in n8n with a webhook
Receive inbound email in n8n with a webhook ReceiveHQ receives mail for your domain (MX → mx.receivehq.com) and POSTs each message to an HTTPS URL. n8n's Webhook node can be that URL. 1. Decide the payload fo
Receive inbound email in n8n with a webhook
ReceiveHQ receives mail for your domain (MX → mx.receivehq.com) and POSTs each message to an HTTPS URL. n8n's Webhook node can be that URL.
1. Decide the payload format
Create a ReceiveHQ webhook endpoint and pick the format your workflow will read:
ReceiveHQ payloadFormat id |
Content-Type | Useful n8n fields |
|---|---|---|
postmark (default) |
application/json |
From, To, OriginalRecipient, Subject, TextBody, HtmlBody, MessageID, Attachments
|
mailgun_sendgrid |
multipart/form-data |
SendGrid-style from, to, subject, text, html, envelope; attachments as attachment1, attachment2, … |
The format id is mailgun_sendgrid (underscore). Stick to one format. Switching from Postmark JSON to multipart (or the reverse) without updating the parser looks like “empty” fields even when the delivery returned 2xx.
ReceiveHQ does not send provider HMAC headers. Use HTTPS plus optional Basic auth, or a secret in the path or query.
2. Webhook node
In an n8n workflow:
- Add a Webhook node.
- HTTP method: POST.
- Set a path (for example
receivehq-inbound). n8n will show a production HTTPS URL once the workflow is active — that is the URL you paste into ReceiveHQ. - Respond immediately with a success code (2xx). ReceiveHQ treats 2xx as acknowledged. 406 permanently drops the message. Any other status is retried (1m → 5m → 30m → 1h → 2h), up to the endpoint's
maxAttemptssetting. Do slower work in later nodes after the 2xx. - If you enabled Basic auth on the ReceiveHQ endpoint (
basicAuthUser/basicAuthPass), turn on Basic Auth on the Webhook node with the same username and password. ReceiveHQ sendsAuthorization: Basic <base64(user:pass)>.
If your Webhook node offers a “Respond” / “Response code” option, set 200 or 204 and respond before long-running branches.
3. Read the body
Postmark JSON: the parsed object is the JSON body. In later nodes, reference fields such as {{ $json.Subject }}, {{ $json.From }}, {{ $json.TextBody }}, {{ $json.MessageID }}. Attachments are an array of { Name, Content, ContentType, ContentLength, ContentID } with Content in base64 — decode before writing a file.
Mailgun / SendGrid multipart: fields arrive as form data (text / html or body-plain / body-html, plus binary parts). Each attachment is sent twice (attachment1 and attachment-1) as raw binary, not base64.
Use MessageID (Postmark format) or another stable id as a dedupe key. Retries are at-least-once.
User-Agent is receivehq-inbound/1.0 if you want a simple sanity check. Do not treat it as authentication.
4. Point mail at ReceiveHQ
- Sign up at receivehq.com, create a tenant and inbound domain, and point MX at
mx.receivehq.com. - Create the webhook endpoint with the n8n production URL, the chosen format, and optional Basic auth on the endpoint.
- Send a test message. Confirm the delivery in the console and in the n8n execution log.
The first 10 emails per tenant are free (up to 3 trial tenants). After that the tenant stays locked until you subscribe (€10/month or €100/year for 100,000 inbound emails, then €10 per additional 100,000).
Further reading
If you want inbound mail in n8n without running a mail server, ReceiveHQ can POST each message to a Webhook node like this one.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.