Send Email From an n8n Workflow via JustEmails
Send transactional emails from n8n workflows using the JustEmails API — no SMTP config, no external relay. Step-by-step with HTTP Request node setup.
Send transactional emails from n8n workflows using the JustEmails API — no SMTP config, no external relay. Step-by-step with HTTP Request node setup.
Picture a 3 AM disk alert. The workflow catches it, processes it, and then nothing happens. The SMTP relay configured months earlier has quietly died, and the notification sits in a queue nobody knows exists. The full disk gets noticed only when the server crashes hours later.
Silent failures like that are a good reason to stop trusting SMTP for workflow alerts.
We're the JustEmails team — JustEmails is built by Velocity Digital Labs, the same folks behind ClickzProtect for bot detection and JustAnalytics for privacy-first analytics. We've written about connecting to Zapier before, but n8n is a different beast. Self-hosted. Open source. Full control. And the audience building automations on n8n tends to want things done without third-party dependencies — which is exactly why the HTTP Request node approach beats wiring up external SMTP relays.
This tutorial walks through how to send email from n8n using the JustEmails API. No SMTP. No Mailgun relay. Just one HTTP Request node, your API key, and JSON. If you're weighing SMTP vs API for transactional email, this walkthrough makes the case for API.
A working n8n workflow that sends email from your custom domain whenever a trigger fires. We'll use a webhook trigger as the example (the most flexible option), but the HTTP Request node pattern works with any n8n trigger — cron schedules, database changes, RSS feeds, whatever. Your emails will come from your domain with proper SPF/DKIM authentication.
Before starting:
API access requires a paid plan. This tutorial runs on the transactional API, and API access is not included in the 7-day trial — a trial account cannot issue the key Step 1 asks for, so there is no way to complete this walkthrough without subscribing first.
Quick note on sending limits: JustEmails includes 1,000 transactional API emails per month on the base $49/year plan, with extra capacity at $25/year per 10,000/month tier. The ceiling to build your workflow around is the daily one — sends are capped per account per day: no more than 50 a day in the first week after a domain is verified, 200 in the second, and up to 500 from day 15, with mailbox sends and API sends counted against the same number, so a tier raises the monthly allowance rather than that daily cap. For most automation workflows — alerts, confirmations, status notifications — that's plenty.
Log into JustEmails, open Settings → API keys and create a new key. As flagged in the prerequisites, this screen is paid-plan only — a trial account cannot create this key.
Name it something you'll recognize later. "n8n Alerts" or "Workflow Notifications" — something that tells future-you what this key is for when you're auditing credentials in six months.
JustEmails shows the key once. Copy it immediately. Paste it into your password manager or a secure note before doing anything else.
The key is je_ followed by 64 hex characters. There are no live or test variants and no test mode: every key sends real mail, so point your first experiments at an address you own.
Open n8n. Click "Add workflow" (or the + icon, depending on your version).
For this tutorial, we'll start with a Webhook trigger. This is the most flexible — you can hit it from external systems, test it manually, or chain it behind other workflows.
/send-alertClick "Listen for Test Event" and keep it running. We'll use this to test later.
(If you're triggering on something else — a Schedule node for daily reports, a Postgres trigger for database changes, an RSS Feed node — the pattern stays the same. The HTTP Request node at the end works identically.)
This is where the JustEmails API call happens.
Now configure the HTTP Request:
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://justemails.app/api/v1/send |
| Authentication | Header Auth |
| Header Name | Authorization |
| Header Value | Bearer je_xxxxxxxx… |
Replace je_xxxxxxxx… with your actual API key from Step 1. And note the URL: the API is served from justemails.app under /api/v1, not from an api. subdomain. There is no api.justemails.app — it has no DNS record at all, so a workflow pointed there fails on name resolution and n8n reports it as a connection error rather than anything email-shaped.
For the Body, select "JSON" and add:
{
"to": "recipient@example.com",
"from": "alerts@yourdomain.com",
"subject": "Alert: Something needs attention",
"html": "<p>This is your alert message.</p>"
}
That's a static test. It'll send the same email every time. We'll make it dynamic in Step 5. The from address has to be a mailbox or alias on a verified domain you own; the API docs list the optional fields, such as a plain-text text part.
Before adding dynamic fields, make sure the static version works.
curl -X POST http://localhost:5678/webhook-test/send-alert \
-H "Content-Type: application/json" \
-d '{"test": "data"}'
(Replace the URL with your actual n8n webhook URL — n8n Cloud uses a different hostname. The /webhook-test/ address only answers while n8n is listening for a test event; once the workflow is active, use the /webhook/ production URL instead.)
A successful response looks like:
{
"data": {
"id": "msg_abc123",
"status": "queued",
...
}
}
If you get a 401, your API key is wrong or missing the Bearer prefix. If you get 403, the from address isn't a mailbox or alias on a verified domain in your account. Common gotchas.
Static emails are useless. The whole point of automation is that the content changes based on the trigger data.
Edit the HTTP Request node's JSON body to use n8n expressions. The syntax is {{ $json.fieldName }} to pull data from the previous node. The Webhook node puts the posted JSON under body, so fields from the webhook payload are $json.body.fieldName.
{
"to": "{{ $json.body.email }}",
"from": "alerts@yourdomain.com",
"subject": "Alert: {{ $json.body.subject }}",
"html": "<p>{{ $json.body.message }}</p><p>Triggered at: {{ $now.toISO() }}</p>"
}
Now your webhook payload controls the email content. Hit it with:
curl -X POST http://localhost:5678/webhook-test/send-alert \
-H "Content-Type: application/json" \
-d '{
"email": "you@yourdomain.com",
"subject": "Disk usage warning",
"message": "Server prod-1 disk at 92%. Clean up logs."
}'
The email lands with your dynamic subject, message, and timestamp. That's the foundation — everything else is variations on this pattern.
The happy path works. But what happens when the API call fails? By default, n8n stops the workflow on HTTP errors. You probably want something smarter.
First, open the HTTP Request node's Settings and set On Error to Continue, so a failed call passes its error to the next node instead of stopping the workflow. Then add an IF node after the HTTP Request:
{{ $json.data.id }}Now you have two branches:
For critical alerts, chain the false branch to a backup notification — usually a Slack webhook. If the send fails for any reason, at least you know the primary alert failed.
The extra five minutes setting up error handling saves you at 2 AM when you're wondering why nobody got the alert.
Writing HTML in JSON gets ugly fast. Here's a cleaner approach using n8n's Code node for complex templates.
Add a Code node between your trigger and the HTTP Request:
// Build email HTML from the webhook's posted body
const data = $input.first().json.body;
const html = `
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.alert { background: #fef2f2; border-left: 4px solid #ef4444; padding: 16px; }
.timestamp { color: #6b7280; font-size: 14px; margin-top: 16px; }
</style>
</head>
<body>
<h2>${data.subject}</h2>
<div class="alert">
<p>${data.message}</p>
</div>
<p class="timestamp">Alert generated: ${new Date().toISOString()}</p>
</body>
</html>
`;
return [{
json: {
to: data.email,
subject: data.subject,
html: html
}
}];
Then your HTTP Request body simplifies to:
{
"to": "{{ $json.to }}",
"from": "alerts@yourdomain.com",
"subject": "{{ $json.subject }}",
"html": {{ JSON.stringify($json.html) }}
}
Note the html line has no quotes around the expression: JSON.stringify adds them and escapes the double quotes and line breaks in the template, which would otherwise break the JSON body.
Separating template logic from the API call makes both easier to debug. When something looks wrong, you can inspect the Code node's output before it hits the API.
(I'll admit the Code node approach is overkill for simple alerts. But the moment you need conditional sections or loops through data — you'll be glad you started here instead of fighting JSON escape hell.)
401 Unauthorized
Your API key is wrong. Check:
Bearer prefix? (Space after "Bearer" matters.)je_ key, all 64 hex characters, with nothing trimmed?Copy the key fresh from JustEmails dashboard if unsure.
403 Forbidden (sender not verified)
You're trying to send from a domain that isn't verified in JustEmails, or from an address that isn't a mailbox or alias on it. Add the domain in your JustEmails dashboard, configure the DNS records, and wait for verification. JustEmails won't send from unverified domains — intentional security measure. Our custom domain email setup guide walks through DNS configuration if you're stuck here.
400 Bad Request (body isn't valid JSON)
Your payload has a syntax error. The most common cause in n8n: using expressions that output undefined or contain unescaped quotes. Check the HTTP Request node's input data before execution. If a field is missing from your trigger, the expression returns nothing and breaks the JSON.
Fix: Use n8n's $if() function to provide fallbacks: {{ $if($json.body.email, $json.body.email, "fallback@yourdomain.com") }}
Email sends but goes to spam
Check your domain's email authentication. JustEmails auto-configures SPF/DKIM/DMARC, but if you added records manually, something might be off. Run your domain through MXToolbox. Our DMARC enforcement guide covers the setup if you need it.
n8n can't reach justemails.app
First check the hostname in the node. ENOTFOUND api.justemails.app isn't a network problem — that subdomain doesn't exist, and the URL should be https://justemails.app/api/v1/....
If the hostname is right and it still fails, and you're running n8n in Docker, the container might have network restrictions. Test with:
docker exec -it n8n curl -I https://justemails.app/api/v1/send
If that fails, check your Docker network configuration or firewall rules. Outbound HTTPS should work on most setups, but corporate proxies and strict VPCs can interfere.
The webhook trigger is generic. Here are patterns that actually solve problems:
Server monitoring alerts: Trigger on a Schedule node (every 5 minutes), use an HTTP Request to check your monitoring endpoint, use IF to check thresholds, send email when disk/CPU/memory exceeds limits. Pair this with JustAnalytics for website uptime monitoring on the same infrastructure.
Form submission confirmations: Trigger on a Webhook that your form posts to. Pull the submitter's email from the payload. Send a confirmation that their message was received. This replaces generic form-builder notifications with branded emails from your domain.
Daily digest emails: Trigger on Schedule (once daily). Query your database or API for the day's events. Build an HTML summary in a Code node. Send to a list of recipients. Daily ad-spend summaries are a common example. If you're comparing JustEmails vs Google Workspace for transactional sends, this is where our API pricing shines.
Error alerting from other workflows: Add a final Error Trigger node to critical workflows. When they fail, it fires. Send yourself (or your team) an email with the error details. Way better than checking n8n's execution logs manually.
My hot take: n8n's error handling is underrated. Most tutorials skip it entirely. Don't be most tutorials.
You've got the basics working. Here's what to explore:
For workflows that send different email types (alerts vs. confirmations vs. digests), create reusable sub-workflows. n8n's Execute Workflow node lets you call a shared "send email" workflow from multiple places — change the template once, it updates everywhere.
Keep an eye on your monthly API sends. The base plan includes 1,000/month. If you're approaching that, the 10,000/month add-on runs $25/year — though remember it lifts the monthly allowance, not the daily sending ceiling. If you're migrating from another provider, our Google Workspace migration guide covers the DNS switchover process.
If you're also hosting regular mailbox email on JustEmails, your transactional sends share the same domain reputation. One platform, one deliverability profile. Less to manage. For the full setup, see our custom domain email guide.
Already using Zapier for other automations? We have a Zapier + JustEmails tutorial that covers the same HTTP webhook pattern in that ecosystem. The approach is nearly identical.
Not yet. JustEmails connects to n8n via the HTTP Request node, which works with any REST API. You configure your API key in the header and build the JSON payload with dynamic fields from earlier workflow nodes. This approach is actually more flexible than a dedicated node — you control the exact request structure.
You can, but it requires SMTP configuration. The HTTP Request approach using JustEmails API is simpler for self-hosted n8n instances where SMTP ports might be blocked, and you get better error responses. Plus you avoid managing SMTP credentials separately from your API key.
The base $49/year plan includes 1,000 transactional API emails per month. If your workflows send more, add 10,000 emails/month for $25/year. A tier raises the monthly allowance only — the daily sending ceiling still applies to API sends. Most automation workflows (alerts, confirmations, notifications) stay well under 1,000/month.
The HTTP Request node returns the error response from JustEmails — status codes like 401 for auth errors, 400 for bad payloads, 403 for a sender address that isn't on a verified domain. Set the node's On Error setting to Continue, then add an IF node after it to check the response and route failures to a separate error-handling branch. n8n also has built-in retry logic you can enable per node.
Unlimited custom domain email hosting for $49/year flat — unlimited domains, unlimited mailboxes, 10 GB storage, full IMAP/SMTP. Built for agencies, freelancers, and anyone managing email across more than one domain.